]> git.tdb.fi Git - libs/gl.git/blobdiff - source/instancescene.h
Change Scene into an abstract base class and add a few subclasses
[libs/gl.git] / source / instancescene.h
diff --git a/source/instancescene.h b/source/instancescene.h
new file mode 100644 (file)
index 0000000..1f79d76
--- /dev/null
@@ -0,0 +1,45 @@
+/* $Id$
+
+This file is part of libmspgl
+Copyright © 2007-2008, 2010  Mikko Rasa, Mikkosoft Productions
+Distributed under the LGPL
+*/
+
+#ifndef MSP_GL_INSTANCESCENE_H_
+#define MSP_GL_INSTANCESCENE_H_
+
+#include <map>
+#include <set>
+#include "scene.h"
+
+namespace Msp {
+namespace GL {
+
+class Object;
+class ObjectInstance;
+
+/**
+A Scene optimized for rendering ObjectInstances.  All instances of the same
+Object are rendered in one go; otherwise the rendering order is unspecified.
+*/
+class InstanceScene: public Scene
+{
+private:
+       typedef std::set<const ObjectInstance *> InstanceSet;
+       typedef std::map<const Object *, InstanceSet> ObjectMap;
+       typedef std::set<const Renderable *> RenderableSet;
+
+       ObjectMap objects;
+       RenderableSet renderables;
+
+public:
+       virtual void add(const Renderable &);
+       virtual void remove(const Renderable &);
+
+       virtual void render(const Tag &tag = Tag()) const;
+};
+
+} // namespace GL
+} // namespace Msp
+
+#endif