32 #ifndef Renderable_INCLUDE_ONCE 33 #define Renderable_INCLUDE_ONCE 64 VL_DEBUG_SET_OBJECT_NAME()
69 Renderable(): mBoundsUpdateTick(0), mDisplayList(0), mBoundsDirty(true),
70 mDisplayListEnabled(false), mDisplayListDirty(true), mBufferObjectEnabled(true), mBufferObjectDirty(true){}
81 if (isDisplayListEnabled())
83 if ( displayListDirty() )
90 glNewList( displayList(), GL_COMPILE_AND_EXECUTE );
VL_CHECK_OGL();
91 render_Implementation( actor, shader, camera, gl_context );
VL_CHECK_OGL();
93 setDisplayListDirty(
false );
98 glCallList( displayList() );
104 if (isBufferObjectEnabled() && isBufferObjectDirty())
107 setBufferObjectDirty(
false);
111 render_Implementation( actor, shader, camera, gl_context );
VL_CHECK_OGL();
117 void computeBounds() { computeBounds_Implementation(); setBoundsDirty(
false); }
136 setBoundsDirty(
false);
142 if (mSphere != sphere)
147 setBoundsDirty(
false);
154 vl::Log::warning(
"Renderable::boundingBox() returning dirty bounding box, call computeBounds() first or call boundingBox() from a non-const Renderable!\n");
162 vl::Log::warning(
"Renderable::boundingSphere() returning dirty bounding sphere, call computeBounds() first or call boundingSphere() from a non-const Renderable!\n");
218 virtual void deleteBufferObject() = 0;
224 glDeleteLists(displayList(), 1);
229 virtual void computeBounds_Implementation() = 0;
233 long long mBoundsUpdateTick;
234 unsigned int mDisplayList;
236 bool mDisplayListEnabled;
237 bool mDisplayListDirty;
238 bool mBufferObjectEnabled;
239 bool mBufferObjectDirty;
Associates a Renderable object to an Effect and Transform.
void setBufferObjectDirty(bool dirty=true)
Whether BufferObjects associated to a Renderable should be recomputed on the next rendering...
static void warning(const String &message)
Use this function to provide information about situations that might lead to errors or loss of data...
virtual ~Renderable()
Destructor.
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
bool boundsDirty() const
Returns whether the bounding sphere or bounding box are "dirty", that is, meant to be recomputed...
void setBoundsDirty(bool dirty)
Marks the bounding box and bounding sphere as dirty in order to be recomputed at the next rendering...
bool isBufferObjectEnabled() const
Returns true if BufferObject (vertex buffer object) are enabled for a Renderable (enabled by default)...
void setBoundingSphere(const Sphere &sphere)
Sets the bounding sphere of a Renderable.
void deleteDisplayList()
Deletes the display list currently associated to a Renderable.
void setBoundingBox(const AABB &aabb)
Sets the bounding box of a Renderable.
bool displayListDirty() const
Whether the display list associated to a Renderable should be recompiled at the next rendering...
bool isDisplayListEnabled() const
Returns true if display lists are enabled for a Renderable (disabled by default). ...
const AABB & boundingBox()
Returns the bounding box of a Renderable recomputing the bounds if dirty.
Visualization Library main namespace.
void setDisplayListDirty(bool dirty)
Whether the display list associated to a Renderable should be recompiled at the next rendering...
void setDisplayList(unsigned int disp_list)
Manually assciates a display list to a Renderable (to be used with care).
The AABB class implements an axis-aligned bounding box using vl::real precision.
The base class for all the reference counted objects.
An abstract class that represents all the objects that can be rendered.
Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects...
The Sphere class defines a sphere using a center and a radius using vl::real precision.
void render(const Actor *actor, const Shader *shader, const Camera *camera, OpenGLContext *gl_context)
Renders the Renderable and if necessary compiles the display list and updates the BufferObjects...
#define VLGRAPHICS_EXPORT
Keeps the local buffer on RAM and updates the BufferObject only if it is marked as dirty...
void setDisplayListEnabled(bool enabled)
Enable/disable display lists (disabled by default).
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
void computeBounds()
Recomputes the bounding box and bounding sphere of a Renderable.
bool isBufferObjectDirty() const
Whether BufferObjects associated to a Renderable should be recomputed on the next rendering...
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
const AABB & boundingBox() const
Returns the bounding box of a Renderable without recomputing the bounds if dirty. ...
const Sphere & boundingSphere()
Returns the bounding sphere of a Renderable recomputing the bounds if dirty.
const Sphere & boundingSphere() const
Returns the bounding sphere of a Renderable without recomputing the bounds if dirty.
unsigned int displayList() const
Returns the display list associated to a Renderable or 0 (zero) if no display list is associated...
void setBufferObjectEnabled(bool enabled)
Enable/disable BufferObject (vertex buffer object) (enabled by default).
long long boundsUpdateTick() const
Returns the bounds-update-tick which is a counter incremented every time the bounding box or bounding...