X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frenderable.h;h=3432a87ee77ed4db3c72600061127bef767c768d;hb=f2592f0e67d92043952eb7a2e39df182720cd990;hp=44b3c257b9a79b825e466be5d9d467827c350b38;hpb=b617c5d7b5283ad260a77f01e42e6170cabbc03d;p=libs%2Fgl.git diff --git a/source/renderable.h b/source/renderable.h index 44b3c257..3432a87e 100644 --- a/source/renderable.h +++ b/source/renderable.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifndef MSP_GL_RENDERABLE_H_ #define MSP_GL_RENDERABLE_H_ @@ -14,6 +7,16 @@ Distributed under the LGPL namespace Msp { namespace GL { +class Matrix; +class Renderer; + +/** +Base class for renderable objects. All Renderables must support rendering with +a Renderer, and may optionally provide support for standalone rendering. + +The render methods take a Tag to identify a render pass. It is most commonly +used together with Techniques and Pipelines to implement multipass rendering. +*/ class Renderable { protected: @@ -21,7 +24,22 @@ protected: public: virtual ~Renderable() { } - virtual void render(const Tag &tag = Tag()) const =0; + /** Returns a key used for grouping Renderables in an InstanceScene. The + returned value is treated as opaque. */ + virtual long get_instance_key() const { return 0; } + + /** Returns the model matrix of the Renderable. Null is returned if no such + matrix exists. */ + virtual const Matrix *get_matrix() const { return 0; } + + /** Renders the renderable without a renderer. This can be convenient in + some simple cases, but most renderables don't need to implement this + method. */ + virtual void render(const Tag & = Tag()) const; + + /** Renders the renderable. Implementors should take care to return the + renderer to the state it was in, for example by using Renderer::Push. */ + virtual void render(Renderer &, const Tag & = Tag()) const = 0; }; } // namespace Msp