]> git.tdb.fi Git - libs/gl.git/blob - source/instancescene.h
Require import module names to be identifiers
[libs/gl.git] / source / instancescene.h
1 #ifndef MSP_GL_INSTANCESCENE_H_
2 #define MSP_GL_INSTANCESCENE_H_
3
4 #include <map>
5 #include <set>
6 #include <msp/core/inttypes.h>
7 #include "scene.h"
8
9 namespace Msp {
10 namespace GL {
11
12 /**
13 A Scene optimized for rendering instanced Renderables, such as ObjectInstances.
14 All Renderables with the same instance key are rendered consecutively; within
15 the same key rendering order is unspecified.
16 */
17 class InstanceScene: public Scene
18 {
19 private:
20         typedef std::set<Renderable *> RenderableSet;
21         typedef std::map<IntPtr, RenderableSet> InstanceMap;
22
23         InstanceMap renderables;
24
25 public:
26         virtual void add(Renderable &);
27         virtual void remove(Renderable &);
28
29         virtual void setup_frame(Renderer &);
30         virtual void finish_frame();
31
32         virtual void render(Renderer &, const Tag &tag = Tag()) const;
33 };
34
35 } // namespace GL
36 } // namespace Msp
37
38 #endif