]> git.tdb.fi Git - libs/gl.git/blob - source/instancescene.cpp
Make RenderPass shprog and shdata settable from code
[libs/gl.git] / source / instancescene.cpp
1 #include "object.h"
2 #include "objectinstance.h"
3 #include "instancescene.h"
4 #include "renderer.h"
5
6 namespace Msp {
7 namespace GL {
8
9 void InstanceScene::add(const Renderable &r)
10 {
11         renderables[r.get_instance_key()].insert(&r);
12 }
13
14 void InstanceScene::remove(const Renderable &r)
15 {
16         InstanceMap::iterator i = renderables.find(r.get_instance_key());
17         if(i!=renderables.end())
18         {
19                 i->second.erase(&r);
20                 if(i->second.empty())
21                         renderables.erase(i);
22         }
23 }
24
25 void InstanceScene::render(Renderer &renderer, const Tag &tag) const
26 {
27         for(InstanceMap::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
28                 for(RenderableSet::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
29                         (*j)->render(renderer, tag);
30 }
31
32 } // namespace GL
33 } // namespace Msp