Visualization Library 2.0.0-b3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
vl::Rendering Class Reference

The Rendering class collects all the information to perform the rendering of a scene. More...

#include <Rendering.hpp>

+ Inheritance diagram for vl::Rendering:

Public Member Functions

 Rendering ()
 Constructor. More...
 
 Rendering (const Rendering &other)
 Copy constructor. More...
 
Renderingoperator= (const Rendering &other)
 Assignment operator. More...
 
virtual void render ()
 Executes the rendering. More...
 
void setRenderQueueSorter (RenderQueueSorter *render_queue_sorter)
 The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting is performed. More...
 
RenderQueueSorterrenderQueueSorter ()
 The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting is performed. More...
 
const Collection< Renderer > & renderers () const
 The list of Renderers used to perform the rendering. More...
 
Collection< Renderer > & renderers ()
 The list of Renderers used to perform the rendering. More...
 
void setRenderer (Renderer *renderer)
 Uitlity function: clears the renderers() list and adds the specified one. More...
 
const Rendererrenderer () const
 Utility function: returns the first renderer installed or NULL if none is found. More...
 
Rendererrenderer ()
 Utility function: returns the first renderer installed or NULL if none is found. More...
 
void setCamera (Camera *camera)
 The Camera that defines the point of view and viewport to be used when rendering the scene. More...
 
const Cameracamera () const
 The Camera that defines the point of view and viewport to be used when rendering the scene. More...
 
Cameracamera ()
 The Camera that defines the point of view and viewport to be used when rendering the scene. More...
 
Collection< SceneManager > * sceneManagers ()
 Returns the list of SceneManager[s] containing the Actor[s] to be rendered. More...
 
const Collection< SceneManager > * sceneManagers () const
 Returns the list of SceneManager[s] containing the Actor[s] to be rendered. More...
 
void setTransform (Transform *transform)
 The root of the Transform tree updated at every rendering frame. More...
 
const Transformtransform () const
 The root of the Transform tree updated at every rendering frame. More...
 
Transformtransform ()
 The root of the Transform tree updated at every rendering frame. More...
 
void setEvaluateLOD (bool evaluate_lod)
 Whether the Level-Of-Detail should be evaluated or not. More...
 
bool evaluateLOD () const
 Whether the Level-Of-Detail should be evaluated or not. More...
 
void setShaderAnimationEnabled (bool animate_shaders)
 Whether Shader::shaderAnimator()->updateShader() should be called or not. More...
 
bool shaderAnimationEnabled () const
 Whether Shader::shaderAnimator()->updateShader() should be called or not. More...
 
void setCullingEnabled (bool enabled)
 Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the rendering performances. More...
 
bool cullingEnabled () const
 Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the rendering performances. More...
 
void setAutomaticResourceInit (bool enable)
 Whether OpenGL resources such as textures and GLSL programs should be automatically initialized when first used. More...
 
bool automaticResourceInit () const
 Whether OpenGL resources such as textures and GLSL programs should be automatically initialized before the rendering takes place. More...
 
bool nearFarClippingPlanesOptimized () const
 Returns whether near/far planes optimization is enabled. More...
 
void setNearFarClippingPlanesOptimized (bool enabled)
 Enabled/disables near/far planes optimization. More...
 
const std::map< unsigned int, ref< Effect > > & effectOverrideMask () const
 A bitmask/Effect map used to everride the Effect of those Actors whose enable mask satisfy the following condition: (Actors::enableMask() & bitmask) != 0. More...
 
std::map< unsigned int, ref< Effect > > & effectOverrideMask ()
 A bitmask/Effect map used to everride the Effect of those Actors whose enable mask satisfy the following condition: (Actors::enableMask() & bitmask) != 0. More...
 
- Public Member Functions inherited from vl::RenderingAbstract
 RenderingAbstract ()
 Constructor. More...
 
RenderingAbstractoperator= (const RenderingAbstract &other)
 
void dispatchOnRenderingStarted ()
 Calls the RenderEventCallback::onRenderingStarted() method of all the active callback objects. More...
 
void dispatchOnRenderingFinished ()
 Calls the RenderEventCallback::onRenderingFinished() method of all the active callback objects. More...
 
Collection< RenderEventCallback > * onStartedCallbacks ()
 Returns the list of RenderEventCallback objects registered to the onRenderingStarted() event notification. More...
 
const Collection< RenderEventCallback > * onStartedCallbacks () const
 Returns the list of RenderEventCallback objects registered to the onRenderingStarted() event notification. More...
 
Collection< RenderEventCallback > * onFinishedCallbacks ()
 Returns the list of RenderEventCallback objects registered to the onRenderingFinished() event notification. More...
 
const Collection< RenderEventCallback > * onFinishedCallbacks () const
 Returns the list of RenderEventCallback objects registered to the onRenderingFinished() event notification. More...
 
void setEnableMask (unsigned int mask)
 The enable mask of the Rendering, used to define wheter the rendering is enabled or not, and which objects should be rendered. More...
 
unsigned int enableMask () const
 The enable mask of the Rendering, used to define wheter the rendering is enabled or not, and which objects should be rendered. More...
 
bool isEnabled (unsigned int mask)
 
bool isEnabled (const Actor *actor)
 
void setFrameClock (real cur_time)
 The update time of the current rendering frame. More...
 
real frameClock () const
 The update time of the current rendering frame. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Member Functions

void fillRenderQueue (ActorCollection *actor_list)
 
RenderQueuerenderQueue ()
 
ActorCollectionactorQueue ()
 
- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Protected Attributes

ref< RenderQueueSortermRenderQueueSorter
 
ref< ActorCollectionmActorQueue
 
ref< RenderQueuemRenderQueue
 
Collection< RenderermRenderers
 
ref< CameramCamera
 
ref< TransformmTransform
 
ref< Collection< SceneManager > > mSceneManagers
 
std::map< unsigned int, ref< Effect > > mEffectOverrideMask
 
bool mAutomaticResourceInit
 
bool mCullingEnabled
 
bool mEvaluateLOD
 
bool mShaderAnimationEnabled
 
bool mNearFarClippingPlanesOptimized
 
- Protected Attributes inherited from vl::RenderingAbstract
ref< Collection< RenderEventCallback > > mOnStartedCallbacks
 
ref< Collection< RenderEventCallback > > mOnFinishedCallbacks
 
real mFrameClock
 
unsigned int mEnableMask
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Detailed Description

The Rendering class collects all the information to perform the rendering of a scene.

The Rendering class performs the following steps:

  1. activates the appropriate OpenGLContext
  2. dispatches the onRenderingStarted() event (see RenderEventCallback class).
  3. activates the Framebuffer's framebuffer and draw buffers
  4. recursively computes the world matrix of the installed Transform hierarchy
  5. setups the Camera transform and the Viewport
  6. extracts all the visible Actor[s] from the installed SceneManager[s]
  7. compiles and sorts the RenderQueue using the installed RenderQueueSorter
  8. uses the installed Renderer to perform the rendering of the RenderQueue
  9. dispatches the onRenderingFinished() event (see RenderEventCallback class).

To be included in the rendering an Actor must have an enableMask() and Effect::enableMask() such that "(Actor::enableMask() & Rendering::enableMask()) != 0" and "(Actor::effect()->enableMask() & Rendering::enableMask()) != 0".

See also

Definition at line 69 of file Rendering.hpp.

Constructor & Destructor Documentation

◆ Rendering() [1/2]

Rendering::Rendering ( )

Constructor.

Definition at line 44 of file Rendering.cpp.

References mActorQueue, mCamera, mRenderers, mRenderQueue, mRenderQueueSorter, mSceneManagers, and mTransform.

◆ Rendering() [2/2]

vl::Rendering::Rendering ( const Rendering other)
inline

Copy constructor.

Definition at line 78 of file Rendering.hpp.

Member Function Documentation

◆ actorQueue()

ActorCollection* vl::Rendering::actorQueue ( )
inlineprotected

Definition at line 212 of file Rendering.hpp.

Referenced by render().

◆ automaticResourceInit()

bool vl::Rendering::automaticResourceInit ( ) const
inline

Whether OpenGL resources such as textures and GLSL programs should be automatically initialized before the rendering takes place.

Definition at line 182 of file Rendering.hpp.

Referenced by fillRenderQueue().

◆ camera() [1/2]

const Camera* vl::Rendering::camera ( ) const
inline

The Camera that defines the point of view and viewport to be used when rendering the scene.

Definition at line 131 of file Rendering.hpp.

Referenced by fillRenderQueue(), vl::Applet::initialize(), render(), and vl::Applet::resizeEvent().

◆ camera() [2/2]

Camera* vl::Rendering::camera ( )
inline

The Camera that defines the point of view and viewport to be used when rendering the scene.

Definition at line 134 of file Rendering.hpp.

◆ cullingEnabled()

bool vl::Rendering::cullingEnabled ( ) const
inline

Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the rendering performances.

Definition at line 174 of file Rendering.hpp.

Referenced by render().

◆ effectOverrideMask() [1/2]

const std::map<unsigned int, ref<Effect> >& vl::Rendering::effectOverrideMask ( ) const
inline

A bitmask/Effect map used to everride the Effect of those Actors whose enable mask satisfy the following condition: (Actors::enableMask() & bitmask) != 0.

Useful when you want to override the Effect of a whole set of Actors. If multiple mask/effect pairs match an Actor's enable mask then the effect with the corresponding lowest mask will be used. See also vl::Actor::enableMask() and vl::Renderer::shaderOverrideMask().

Definition at line 197 of file Rendering.hpp.

◆ effectOverrideMask() [2/2]

std::map<unsigned int, ref<Effect> >& vl::Rendering::effectOverrideMask ( )
inline

A bitmask/Effect map used to everride the Effect of those Actors whose enable mask satisfy the following condition: (Actors::enableMask() & bitmask) != 0.

Useful when you want to override the Effect of a whole set of Actors. If multiple mask/effect pairs match an Actor's enable mask then the effect with the corresponding lowest mask will be used. See also vl::Actor::enableMask() and vl::Renderer::shaderOverrideMask().

Definition at line 203 of file Rendering.hpp.

◆ evaluateLOD()

bool vl::Rendering::evaluateLOD ( ) const
inline

Whether the Level-Of-Detail should be evaluated or not.

When disabled lod #0 is used.

Definition at line 158 of file Rendering.hpp.

Referenced by fillRenderQueue().

◆ fillRenderQueue()

void Rendering::fillRenderQueue ( ActorCollection actor_list)
protected

◆ nearFarClippingPlanesOptimized()

bool vl::Rendering::nearFarClippingPlanesOptimized ( ) const
inline

Returns whether near/far planes optimization is enabled.

Definition at line 185 of file Rendering.hpp.

Referenced by render().

◆ operator=()

Rendering & Rendering::operator= ( const Rendering other)

◆ render()

void Rendering::render ( )
virtual

◆ renderer() [1/2]

const Renderer* vl::Rendering::renderer ( ) const
inline

Utility function: returns the first renderer installed or NULL if none is found.

Definition at line 110 of file Rendering.hpp.

References NULL.

Referenced by vl::Applet::resizeEvent().

◆ renderer() [2/2]

Renderer* vl::Rendering::renderer ( )
inline

Utility function: returns the first renderer installed or NULL if none is found.

Definition at line 119 of file Rendering.hpp.

References NULL.

◆ renderers() [1/2]

const Collection<Renderer>& vl::Rendering::renderers ( ) const
inline

The list of Renderers used to perform the rendering.

The output of one Renderer::render() operation will be fed as input for the next Renderer::render() operation.

Note
All the renderers must target the same OpenGL context.

Definition at line 95 of file Rendering.hpp.

Referenced by render().

◆ renderers() [2/2]

Collection<Renderer>& vl::Rendering::renderers ( )
inline

The list of Renderers used to perform the rendering.

The output of one Renderer::render() operation will be fed as input for the next Renderer::render() operation.

Note
All the renderers must target the same OpenGL context.

Definition at line 100 of file Rendering.hpp.

◆ renderQueue()

RenderQueue* vl::Rendering::renderQueue ( )
inlineprotected

Definition at line 211 of file Rendering.hpp.

Referenced by fillRenderQueue(), and render().

◆ renderQueueSorter()

RenderQueueSorter* vl::Rendering::renderQueueSorter ( )
inline

The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting is performed.

Definition at line 90 of file Rendering.hpp.

Referenced by render().

◆ sceneManagers() [1/2]

Collection<SceneManager>* vl::Rendering::sceneManagers ( )
inline

Returns the list of SceneManager[s] containing the Actor[s] to be rendered.

Definition at line 137 of file Rendering.hpp.

Referenced by vl::TrackballManipulator::adjustView(), vl::EdgeExtractor::extractEdges(), vl::Applet::initialize(), and render().

◆ sceneManagers() [2/2]

const Collection<SceneManager>* vl::Rendering::sceneManagers ( ) const
inline

Returns the list of SceneManager[s] containing the Actor[s] to be rendered.

Definition at line 140 of file Rendering.hpp.

◆ setAutomaticResourceInit()

void vl::Rendering::setAutomaticResourceInit ( bool  enable)
inline

Whether OpenGL resources such as textures and GLSL programs should be automatically initialized when first used.

Enabling this features forces VL to keep track of which resources are used for each rendering, which might slighly impact the rendering time, thus to obtain the maximum performances disable this option and manually initialize your textures and GLSL shaders.

Definition at line 179 of file Rendering.hpp.

◆ setCamera()

void vl::Rendering::setCamera ( Camera camera)
inline

The Camera that defines the point of view and viewport to be used when rendering the scene.

Definition at line 128 of file Rendering.hpp.

◆ setCullingEnabled()

void vl::Rendering::setCullingEnabled ( bool  enabled)
inline

Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the rendering performances.

Definition at line 171 of file Rendering.hpp.

◆ setEvaluateLOD()

void vl::Rendering::setEvaluateLOD ( bool  evaluate_lod)
inline

Whether the Level-Of-Detail should be evaluated or not.

When disabled lod #0 is used.

Definition at line 155 of file Rendering.hpp.

◆ setNearFarClippingPlanesOptimized()

void vl::Rendering::setNearFarClippingPlanesOptimized ( bool  enabled)
inline

Enabled/disables near/far planes optimization.

When enabled, the automatic near/far clipping planes optimization modifies the projection matrix of the current camera to minimize z-fighting artifacts. If later you disable this feature you might want to recompute the original projection matrix of the camera using the method vl::Camera::setProjectionPerspective().

Definition at line 191 of file Rendering.hpp.

◆ setRenderer()

void vl::Rendering::setRenderer ( Renderer renderer)
inline

Uitlity function: clears the renderers() list and adds the specified one.

Definition at line 103 of file Rendering.hpp.

◆ setRenderQueueSorter()

void vl::Rendering::setRenderQueueSorter ( RenderQueueSorter render_queue_sorter)
inline

The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting is performed.

Definition at line 87 of file Rendering.hpp.

◆ setShaderAnimationEnabled()

void vl::Rendering::setShaderAnimationEnabled ( bool  animate_shaders)
inline

Whether Shader::shaderAnimator()->updateShader() should be called or not.

Note
Only Shader[s] belonging to visible Actor[s] are animated.

Definition at line 163 of file Rendering.hpp.

◆ setTransform()

void vl::Rendering::setTransform ( Transform transform)
inline

The root of the Transform tree updated at every rendering frame.

For more information about how and when using it see the documentation of Transform.

Definition at line 144 of file Rendering.hpp.

◆ shaderAnimationEnabled()

bool vl::Rendering::shaderAnimationEnabled ( ) const
inline

Whether Shader::shaderAnimator()->updateShader() should be called or not.

Note
Only Shader[s] belonging to visible Actor[s] are animated.

Definition at line 168 of file Rendering.hpp.

Referenced by fillRenderQueue().

◆ transform() [1/2]

const Transform* vl::Rendering::transform ( ) const
inline

The root of the Transform tree updated at every rendering frame.

For more information about how and when using it see the documentation of Transform.

Definition at line 148 of file Rendering.hpp.

Referenced by render().

◆ transform() [2/2]

Transform* vl::Rendering::transform ( )
inline

The root of the Transform tree updated at every rendering frame.

For more information about how and when using it see the documentation of Transform.

Definition at line 152 of file Rendering.hpp.

Member Data Documentation

◆ mActorQueue

ref<ActorCollection> vl::Rendering::mActorQueue
protected

Definition at line 216 of file Rendering.hpp.

Referenced by Rendering().

◆ mAutomaticResourceInit

bool vl::Rendering::mAutomaticResourceInit
protected

Definition at line 224 of file Rendering.hpp.

Referenced by operator=().

◆ mCamera

ref<Camera> vl::Rendering::mCamera
protected

Definition at line 219 of file Rendering.hpp.

Referenced by operator=(), and Rendering().

◆ mCullingEnabled

bool vl::Rendering::mCullingEnabled
protected

Definition at line 225 of file Rendering.hpp.

Referenced by operator=().

◆ mEffectOverrideMask

std::map<unsigned int, ref<Effect> > vl::Rendering::mEffectOverrideMask
protected

Definition at line 222 of file Rendering.hpp.

Referenced by fillRenderQueue().

◆ mEvaluateLOD

bool vl::Rendering::mEvaluateLOD
protected

Definition at line 226 of file Rendering.hpp.

Referenced by operator=().

◆ mNearFarClippingPlanesOptimized

bool vl::Rendering::mNearFarClippingPlanesOptimized
protected

Definition at line 228 of file Rendering.hpp.

Referenced by operator=().

◆ mRenderers

Collection<Renderer> vl::Rendering::mRenderers
protected

Definition at line 218 of file Rendering.hpp.

Referenced by operator=(), and Rendering().

◆ mRenderQueue

ref<RenderQueue> vl::Rendering::mRenderQueue
protected

Definition at line 217 of file Rendering.hpp.

Referenced by Rendering().

◆ mRenderQueueSorter

ref<RenderQueueSorter> vl::Rendering::mRenderQueueSorter
protected

Definition at line 215 of file Rendering.hpp.

Referenced by operator=(), and Rendering().

◆ mSceneManagers

ref<Collection<SceneManager> > vl::Rendering::mSceneManagers
protected

Definition at line 221 of file Rendering.hpp.

Referenced by operator=(), and Rendering().

◆ mShaderAnimationEnabled

bool vl::Rendering::mShaderAnimationEnabled
protected

Definition at line 227 of file Rendering.hpp.

Referenced by operator=().

◆ mTransform

ref<Transform> vl::Rendering::mTransform
protected

Definition at line 220 of file Rendering.hpp.

Referenced by operator=(), and Rendering().


The documentation for this class was generated from the following files: