32 #ifndef Renderable_INCLUDE_ONCE 33 #define Renderable_INCLUDE_ONCE 64 VL_DEBUG_SET_OBJECT_NAME()
69 Renderable& operator=(
const Renderable&) =
default;
73 Renderable(): mBoundsUpdateTick(0), mDisplayList(0), mBoundsDirty(true),
74 mDisplayListEnabled(false), mDisplayListDirty(true), mBufferObjectEnabled(true), mBufferObjectDirty(true){}
85 if (isDisplayListEnabled())
87 if ( displayListDirty() )
94 glNewList( displayList(), GL_COMPILE_AND_EXECUTE );
VL_CHECK_OGL();
95 render_Implementation( actor, shader, camera, gl_context );
VL_CHECK_OGL();
97 setDisplayListDirty(
false );
102 glCallList( displayList() );
108 if (isBufferObjectEnabled() && isBufferObjectDirty())
111 setBufferObjectDirty(
false);
115 render_Implementation( actor, shader, camera, gl_context );
VL_CHECK_OGL();
121 void computeBounds() { computeBounds_Implementation(); setBoundsDirty(
false); }
140 setBoundsDirty(
false);
146 if (mSphere != sphere)
151 setBoundsDirty(
false);
158 vl::Log::warning(
"Renderable::boundingBox() returning dirty bounding box, call computeBounds() first or call boundingBox() from a non-const Renderable!\n");
166 vl::Log::warning(
"Renderable::boundingSphere() returning dirty bounding sphere, call computeBounds() first or call boundingSphere() from a non-const Renderable!\n");
222 virtual void deleteBufferObject() = 0;
228 glDeleteLists(displayList(), 1);
233 virtual void computeBounds_Implementation() = 0;
237 long long mBoundsUpdateTick;
238 unsigned int mDisplayList;
240 bool mDisplayListEnabled;
241 bool mDisplayListDirty;
242 bool mBufferObjectEnabled;
243 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...