]> git.tdb.fi Git - libs/gl.git/blob - source/objectinstance.h
Drop Id tags and copyright notices from files
[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.  An application can derive another
15 class from this and overload the hook functions to specify location and other
16 instance-specific parameters for the rendered objects.
17 */
18 class ObjectInstance: public Renderable
19 {
20 protected:
21         const Object &object;
22
23 public:
24         ObjectInstance(const Object &);
25
26         const Object &get_object() const { return object; }
27         virtual long get_instance_key() const { return reinterpret_cast<long>(&object); }
28
29         virtual void render(const Tag &tag = Tag()) const;
30         virtual void render(Renderer &, const Tag & = Tag()) const;
31
32         /** Hook function, called from Object just before rendering the mesh.
33         Renderer state will have been pushed before this is called. */
34         virtual void setup_render(Renderer &, const Tag &) const { }
35
36         /** Hook function, called from Object right after rendering the mesh.  Since
37         Object takes care of pushing Renderer state, this rarely needs to do
38         anything. */
39         virtual void finish_render(Renderer &, const Tag &) const { }
40
41         virtual unsigned get_level_of_detail() const { return 0; }
42 };
43
44 } // namespace GL
45 } // namespaec Msp
46
47 #endif