1 #ifndef MSP_GL_RENDERABLE_H_
2 #define MSP_GL_RENDERABLE_H_
14 Base class for renderable objects. All Renderables must support rendering with
15 a Renderer, and may optionally provide support for standalone rendering.
17 The render methods take a Tag to identify a render pass. It is most commonly
18 used together with Techniques and Pipelines to implement multipass rendering.
20 The setup_frame and finish_frame methods provide a mechanism for performing
21 once-per-frame operations. This is most useful for effects, which may need to
22 do auxiliary rendering. With complex rendering hierarchies, these methods may
23 be called multiple times for one frame, but it's guaranteed that no rendering
24 will occur before a setup_frame call or after a finish_frame call.
31 virtual ~Renderable() { }
33 /** Returns a key used for grouping Renderables in an InstanceScene. The
34 returned value is treated as opaque. */
35 virtual long get_instance_key() const { return 0; }
37 /** Returns the model matrix of the Renderable. Null is returned if no such
39 virtual const Matrix *get_matrix() const { return 0; }
41 /** Called when starting to render a new frame. */
42 virtual void setup_frame() const { }
44 /** Called when a complete frame has been rendered. */
45 virtual void finish_frame() const { }
47 /** Renders the renderable without a renderer. This can be convenient in
48 some simple cases, but most renderables don't need to implement this
50 virtual void render(const Tag & = Tag()) const;
52 /** Renders the renderable. Implementors should take care to return the
53 renderer to the state it was in, for example by using Renderer::Push. */
54 virtual void render(Renderer &, const Tag & = Tag()) const = 0;