]> git.tdb.fi Git - libs/gl.git/blob - source/scene.h
Remove dynamic allocation from VertexFormat
[libs/gl.git] / source / scene.h
1 #ifndef MSP_GL_SCENE_H_
2 #define MSP_GL_SCENE_H_
3
4 #include <list>
5 #include <msp/datafile/objectloader.h>
6 #include "matrix.h"
7 #include "renderable.h"
8 #include "vector.h"
9
10 namespace Msp {
11 namespace GL {
12
13 /**
14 Scenes are containers for other Renderables.  This is a base class that can't
15 be instantiated.  Examples of available Scene types are SimpleScene,
16 InstancedScene and OrderedScene.
17 */
18 class Scene: public Renderable
19 {
20 public:
21         class Loader: public DataFile::CollectionObjectLoader<Scene>
22         {
23         public:
24                 Loader(Scene &, Collection &);
25
26         private:
27                 void object(const std::string &);
28         };
29
30 protected:
31         std::list<Renderable *> owned_data;
32         mutable Matrix culling_matrix;
33         mutable Vector4 frustum_edges[6];
34
35         Scene() { }
36 private:
37         Scene(const Scene &);
38         Scene &operator=(const Scene &);
39 public:
40         virtual ~Scene();
41
42         virtual void add(const Renderable &) = 0;
43         virtual void remove(const Renderable &) = 0;
44
45         using Renderable::render;
46         virtual void render(const Tag & = Tag()) const;
47
48 protected:
49         bool setup_frustum(const Renderer &) const;
50         bool frustum_cull(const Renderable &) const;
51 };
52
53 } // namespace GL
54 } // namespace Msp
55
56 #endif