]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/instancescene.h
Rearrange soucre files into subdirectories
[libs/gl.git] / source / render / instancescene.h
diff --git a/source/render/instancescene.h b/source/render/instancescene.h
new file mode 100644 (file)
index 0000000..a5ac2cd
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef MSP_GL_INSTANCESCENE_H_
+#define MSP_GL_INSTANCESCENE_H_
+
+#include <map>
+#include <set>
+#include <msp/core/inttypes.h>
+#include "scene.h"
+
+namespace Msp {
+namespace GL {
+
+/**
+A Scene optimized for rendering instanced Renderables, such as ObjectInstances.
+All Renderables with the same instance key are rendered consecutively; within
+the same key rendering order is unspecified.
+*/
+class InstanceScene: public Scene
+{
+private:
+       typedef std::set<Renderable *> RenderableSet;
+       typedef std::map<IntPtr, RenderableSet> InstanceMap;
+
+       InstanceMap renderables;
+
+public:
+       virtual void add(Renderable &);
+       virtual void remove(Renderable &);
+
+       virtual void setup_frame(Renderer &);
+       virtual void finish_frame();
+
+       virtual void render(Renderer &, const Tag &tag = Tag()) const;
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif