]> git.tdb.fi Git - libs/gl.git/blob - source/instancescene.h
Change Scene into an abstract base class and add a few subclasses
[libs/gl.git] / source / instancescene.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007-2008, 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_INSTANCESCENE_H_
9 #define MSP_GL_INSTANCESCENE_H_
10
11 #include <map>
12 #include <set>
13 #include "scene.h"
14
15 namespace Msp {
16 namespace GL {
17
18 class Object;
19 class ObjectInstance;
20
21 /**
22 A Scene optimized for rendering ObjectInstances.  All instances of the same
23 Object are rendered in one go; otherwise the rendering order is unspecified.
24 */
25 class InstanceScene: public Scene
26 {
27 private:
28         typedef std::set<const ObjectInstance *> InstanceSet;
29         typedef std::map<const Object *, InstanceSet> ObjectMap;
30         typedef std::set<const Renderable *> RenderableSet;
31
32         ObjectMap objects;
33         RenderableSet renderables;
34
35 public:
36         virtual void add(const Renderable &);
37         virtual void remove(const Renderable &);
38
39         virtual void render(const Tag &tag = Tag()) const;
40 };
41
42 } // namespace GL
43 } // namespace Msp
44
45 #endif