]> git.tdb.fi Git - libs/gl.git/blob - source/objectinstance.h
Lots of comment updates
[libs/gl.git] / source / objectinstance.h
1 #ifndef MSP_GL_OBJETCINSTANCE_H_
2 #define MSP_GL_OBJETCINSTANCE_H_
3
4 #include <string>
5 #include "renderable.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Object;
11 class ProgramData;
12
13 /**
14 Represents a single instance of an Object.  A derived class can overload the
15 hook functions to specify a model matrix and other instance-specific parameters
16 for the rendered objects.
17
18 ObjectInstances can benefit from being put in an InstanceScene, which will
19 render all instances of the same object consecutively.
20 */
21 class ObjectInstance: public Renderable
22 {
23 protected:
24         const Object &object;
25
26 public:
27         ObjectInstance(const Object &);
28
29         const Object &get_object() const { return object; }
30         virtual long get_instance_key() const { return reinterpret_cast<long>(&object); }
31
32         virtual void render(const Tag &tag = Tag()) const;
33         virtual void render(Renderer &, const Tag & = Tag()) const;
34
35         /** Hook function, called from Object just before rendering the mesh.
36         Renderer state will have been pushed before this is called. */
37         virtual void setup_render(Renderer &, const Tag &) const { }
38
39         /** Hook function, called from Object right after rendering the mesh.  Since
40         Object takes care of pushing Renderer state, this rarely needs to do
41         anything. */
42         virtual void finish_render(Renderer &, const Tag &) const { }
43
44         virtual unsigned get_level_of_detail() const { return 0; }
45 };
46
47 } // namespace GL
48 } // namespaec Msp
49
50 #endif