1 #ifndef MSP_GL_RENDERABLE_H_
2 #define MSP_GL_RENDERABLE_H_
5 #include <msp/core/attributes.h>
6 #include <msp/core/inttypes.h>
7 #include <msp/geometry/boundingsphere.h>
17 Base class for renderable objects. Rendering is performed with the help of a
20 The render method takes a Tag to identify a render pass. It can be used with
21 a Technique to select alternative rendering methods, such as simplified shaders
22 for a depth-only shadow pass.
24 The setup_frame and finish_frame methods provide a mechanism for performing
25 once-per-frame operations. This is most useful for effects, which may need to
26 do auxiliary rendering. With complex rendering hierarchies, these methods may
27 be called multiple times for one frame, but it's guaranteed that no rendering
28 will occur before a setup_frame call or after a finish_frame call.
35 virtual ~Renderable() { }
37 /** Returns a key used for grouping Renderables in an InstanceScene. The
38 returned value is treated as opaque. */
39 DEPRECATED virtual IntPtr get_instance_key() const { return 0; }
41 /** Returns the model matrix of the Renderable. Null is returned if no such
42 matrix exists. The matrix should be in world space for some effects to work
44 virtual const Matrix *get_matrix() const { return 0; }
46 /** Returns a bounding sphere that completely encloses the Renderable. The
47 bounding sphere is expressed in the renderable's coordinates. Null is
48 returned if the bounding sphere cannot be determined. */
49 virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return 0; }
51 /** Called when starting to render a new frame. */
52 virtual void setup_frame(Renderer &) { }
54 /** Called when a complete frame has been rendered. */
55 virtual void finish_frame() { }
57 /** Renders the Renderable. Implementors should take care to return the
58 renderer to the state it was in, for example by using Renderer::Push. */
59 virtual void render(Renderer &, Tag = Tag()) const = 0;