]> git.tdb.fi Git - libs/gl.git/blob - source/renderable.h
Lots of comment updates
[libs/gl.git] / source / renderable.h
1 #ifndef MSP_GL_RENDERABLE_H_
2 #define MSP_GL_RENDERABLE_H_
3
4 #include <string>
5 #include "tag.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Renderer;
11
12 /**
13 Base class for renderable objects.  All Renderables must support rendering with
14 a Renderer, and may optionally provide support for standalone rendering.
15
16 The render methods take a Tag to identify a render pass.  It is most commonly
17 used together with Techniques and Pipelines to implement multipass rendering.
18 */
19 class Renderable
20 {
21 protected:
22         Renderable() { }
23 public:
24         virtual ~Renderable() { }
25
26         /** Returns a key used for grouping Renderables in an InstanceScene.  The
27         returned value is treated as opaque. */
28         virtual long get_instance_key() const { return 0; }
29
30         /** Renders the renderable without a renderer.  This can be convenient in
31         some simple cases, but most renderables don't need to implement this
32         method. */
33         virtual void render(const Tag & = Tag()) const;
34
35         /** Renders the renderable.  Implementors should take care to return the
36         renderer to the state it was in, for example by using Renderer::Push. */
37         virtual void render(Renderer &, const Tag & = Tag()) const = 0;
38 };
39
40 } // namespace Msp
41 } // namespace GL
42
43 #endif