# Visualization Library

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

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Member Functions | Protected Attributes

# 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:

List of all members.

## Public Member Functions

virtual const char * | className ()
| Returns the name of the class.
| Rendering ()
| Constructor.
| Rendering (const Rendering &other)
| Copy constructor.
Rendering & | operator= (const Rendering &other)
| Assignment operator.
virtual void | render ()
| Executes the rendering.
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.
RenderQueueSorter * | renderQueueSorter ()
| The RenderQueueSorter used to perform the sorting of the objects to be rendered, if NULL no sorting is performed.
const std::vector< ref < Renderer > > & | renderers () const
| The list of Renderers used to perform the rendering.
std::vector< ref< Renderer > > & | renderers ()
| The list of Renderers used to perform the rendering.
void | setRenderer (Renderer *renderer)
| Uitlity function: clears the renderers() list and adds the specified one.
const Renderer * | renderer () const
| Utility function: returns the first renderer installed or NULL if none is found.
Renderer * | renderer ()
| Utility function: returns the first renderer installed or NULL if none is found.
void | setCamera (Camera *camera)
| The Camera that defines the point of view and viewport to be used when rendering the scene.
const Camera * | camera () const
| The Camera that defines the point of view and viewport to be used when rendering the scene.
Camera * | camera ()
| The Camera that defines the point of view and viewport to be used when rendering the scene.
Collection< SceneManager > * | sceneManagers ()
| Returns the list of SceneManager[s] containing the Actor[s] to be rendered.
const Collection< SceneManager > * | sceneManagers () const
| Returns the list of SceneManager[s] containing the Actor[s] to be rendered.
void | setTransform (Transform *transform)
| The root of the Transform tree updated at every rendering frame.
const Transform * | transform () const
| The root of the Transform tree updated at every rendering frame.
Transform * | transform ()
| The root of the Transform tree updated at every rendering frame.
void | setEvaluateLOD (bool evaluate_lod)
| Whether the Level-Of-Detail should be evaluated or not.
bool | evaluateLOD () const
| Whether the Level-Of-Detail should be evaluated or not.
void | setShaderAnimationEnabled (bool animate_shaders)
| Whether Shader::shaderAnimator()->updateShader() should be called or not.
bool | shaderAnimationEnabled () const
| Whether Shader::shaderAnimator()->updateShader() should be called or not.
void | setCullingEnabled (bool enabled)
| Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the rendering performances.
bool | cullingEnabled () const
| Whether the installed SceneManager[s] should perform Actor culling or not in order to maximize the rendering performances.
void | setAutomaticResourceInit (bool enable)
| Whether OpenGL resources such as textures and GLSL programs should be automatically initialized when first used.
bool | automaticResourceInit () const
| Whether OpenGL resources such as textures and GLSL programs should be automatically initialized before the rendering takes place.
bool | nearFarClippingPlanesOptimized () const
| Returns whether near/far planes optimization is enabled.
void | setNearFarClippingPlanesOptimized (bool enabled)
| Enabled/disables near/far planes optimization.
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.
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.

## Protected Member Functions

void | fillRenderQueue (ActorCollection *actor_list)
ActorCollection * | actorQueue ()
RenderQueue * | renderQueue ()

## Protected Attributes

ref< RenderQueueSorter > | mRenderQueueSorter
ref< ActorCollection > | mActorQueue
ref< RenderQueue > | mRenderQueue
std::vector< ref< Renderer > > | mRenderers
ref< Camera > | mCamera
ref< Transform > | mTransform
ref< Collection< SceneManager > > | mSceneManagers
std::map< unsigned int, ref < Effect > > | mEffectOverrideMask
bool | mAutomaticResourceInit
bool | mCullingEnabled
bool | mEvaluateLOD
bool | mShaderAnimationEnabled
bool | mNearFarClippingPlanesOptimized

## 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 RenderTarget'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:

- Renderer
- Actor
- Effect
- Transform

Definition at line 69 of file Rendering.hpp.

## Constructor & Destructor Documentation

Rendering::Rendering | ( | ) |

Constructor.

Definition at line 44 of file Rendering.cpp.

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

vl::Rendering::Rendering | ( | const Rendering & | other ) | `[inline]`

Copy constructor.

Definition at line 78 of file Rendering.hpp.

## Member Function Documentation

virtual const char* vl::Rendering::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::RenderingAbstract.

Definition at line 72 of file Rendering.hpp.

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

Assignment operator.

Definition at line 61 of file Rendering.cpp.

References mAutomaticResourceInit, mCamera, mCullingEnabled, vl::RenderingAbstract::mEnableMask, mEvaluateLOD, mNearFarClippingPlanesOptimized, mRenderers, mRenderQueueSorter, mSceneManagers, mShaderAnimationEnabled, and mTransform.

void Rendering::render | ( | ) | `[virtual]`

Executes the rendering.

Implements vl::RenderingAbstract.

Definition at line 83 of file Rendering.cpp.

References actorQueue(), vl::Collection< T >::at(), vl::Actor::boundingSphere(), vl::SceneManager::boundsDirty(), camera(), vl::RenderQueue::clear(), vl::Collection< T >::clear(), vl::SceneManager::computeBounds(), vl::Camera::computeFrustumPlanes(), vl::Camera::computeNearFarOptimizedProjMatrix(), vl::ITransform::computeWorldMatrixRecursive(), vl::Frustum::cull(), vl::SceneManager::cullingEnabled(), cullingEnabled(), vl::RenderingAbstract::enableMask(), vl::Log::error(), vl::SceneManager::extractActors(), vl::SceneManager::extractVisibleActors(), fillRenderQueue(), vl::RenderingAbstract::frameClock(), vl::Camera::frustum(), vl::RenderingAbstract::isEnabled(), nearFarClippingPlanesOptimized(), vl::Frustum::planes(), renderers(), renderQueue(), renderQueueSorter(), sceneManagers(), vl::Camera::setInverseViewMatrix(), vl::Collection< T >::size(), vl::RenderQueue::sort(), transform(), VL_CHECK, VL_CHECK_OGL, and VL_TRAP.

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.

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().

const std::vector< ref<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().

std::vector< ref<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.

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.

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.

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

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.

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.

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(), render(), and vl::Applet::resizeEvent().

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.

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(), and render().

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.

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.

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* 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.

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.

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().

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.

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().

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.

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().

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.

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().

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().

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::setProjectionAsPerspective().

Definition at line 191 of file Rendering.hpp.

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.

Definition at line 194 of file Rendering.hpp.

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.

Definition at line 197 of file Rendering.hpp.

void Rendering::fillRenderQueue | ( | ActorCollection * | actor_list ) | `[protected]`

Definition at line 266 of file Rendering.cpp.

References vl::Collection< T >::at(), automaticResourceInit(), camera(), vl::Actor::computeBounds(), vl::Texture::createTexture(), vl::Actor::effect(), vl::Collection< T >::empty(), vl::Effect::enableMask(), vl::Actor::enableMask(), vl::RenderingAbstract::enableMask(), vl::Actor::evaluateLOD(), evaluateLOD(), vl::Effect::evaluateLOD(), vl::RenderingAbstract::frameClock(), vl::ref< T >::get(), vl::Shader::glslProgram(), vl::Shader::gocRenderStateSet(), vl::ShaderAnimator::isEnabled(), vl::RenderingAbstract::isEnabled(), vl::Shader::lastUpdateTime(), vl::GLSLProgram::linked(), vl::GLSLProgram::linkProgram(), vl::Effect::lod(), vl::Actor::lod(), vl::RenderToken::mActor, mEffectOverrideMask, vl::RenderToken::mEffectRenderRank, vl::RenderToken::mNextPass, vl::RenderToken::mRenderable, vl::RenderToken::mShader, vl::RenderQueue::newToken(), renderQueue(), vl::Effect::renderRank(), vl::RenderStateSet::renderStates(), vl::RS_TextureUnit0, vl::Shader::setLastUpdateTime(), vl::Texture::setupParams(), shaderAnimationEnabled(), vl::Shader::shaderAnimator(), vl::Collection< T >::size(), vl::TextureUnit::texture(), vl::ShaderAnimator::updateShader(), VL_CHECK, and VL_MAX_TEXTURE_UNITS.

Referenced by render().

ActorCollection* vl::Rendering::actorQueue | ( | ) | `[inline, protected]`

Definition at line 201 of file Rendering.hpp.

Referenced by render().

RenderQueue* vl::Rendering::renderQueue | ( | ) | `[inline, protected]`

Definition at line 202 of file Rendering.hpp.

Referenced by fillRenderQueue(), and render().

## Member Data Documentation

ref<RenderQueueSorter> vl::Rendering::mRenderQueueSorter`[protected]`

Definition at line 205 of file Rendering.hpp.

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

ref<ActorCollection> vl::Rendering::mActorQueue`[protected]`

Definition at line 206 of file Rendering.hpp.

Referenced by Rendering().

ref<RenderQueue> vl::Rendering::mRenderQueue`[protected]`

Definition at line 207 of file Rendering.hpp.

Referenced by Rendering().

std::vector< ref<Renderer> > vl::Rendering::mRenderers`[protected]`

Definition at line 208 of file Rendering.hpp.

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

ref<Camera> vl::Rendering::mCamera`[protected]`

Definition at line 209 of file Rendering.hpp.

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

ref<Transform> vl::Rendering::mTransform`[protected]`

Definition at line 210 of file Rendering.hpp.

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

ref<Collection<SceneManager> > vl::Rendering::mSceneManagers`[protected]`

Definition at line 211 of file Rendering.hpp.

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

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

Definition at line 212 of file Rendering.hpp.

Referenced by fillRenderQueue().

bool vl::Rendering::mAutomaticResourceInit`[protected]`

Definition at line 214 of file Rendering.hpp.

Referenced by operator=().

bool vl::Rendering::mCullingEnabled`[protected]`

Definition at line 215 of file Rendering.hpp.

Referenced by operator=().

bool vl::Rendering::mEvaluateLOD`[protected]`

Definition at line 216 of file Rendering.hpp.

Referenced by operator=().

bool vl::Rendering::mShaderAnimationEnabled`[protected]`

Definition at line 217 of file Rendering.hpp.

Referenced by operator=().

bool vl::Rendering::mNearFarClippingPlanesOptimized`[protected]`

Definition at line 218 of file Rendering.hpp.

Referenced by operator=().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/Rendering.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/Rendering.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:44.
Permission is granted to use this page to write and publish articles regarding Visualization Library.