Developer Documentation

Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
ACG::IRenderer Class Reference
Inheritance diagram for ACG::IRenderer:

## Classes
class | DepthMapPass
struct | LightData
class | RenderObjectRange

## Public Member Functions
virtual void | addRenderObject (RenderObject *_renderObject)
| Callback for the scenegraph nodes, which send new render objects via this function. More...
virtual void | addLight (const LightData &_light)
| Callback for the scenegraph nodes, which send new lights to the renderer via this function. More...
virtual void | addRenderObjectModifier (RenderObjectModifier *_mod)
| Callback for the scenegraph nodes, which adds a render object modifier to the renderer via this function. More...
virtual void | removeRenderObjectModifier (RenderObjectModifier *_mod)
| Callback for the scenegraph nodes, which removes a render object modifier from the renderer. More...
void | dumpRenderObjectsToFile (const char *_fileName, ACG::RenderObject **_sortedList=0) const
| Debugging function to dump list of render objects into a file. More...
virtual QString | dumpCurrentRenderObjectsToString (ACG::RenderObject **_list=0, bool _outputShaders=false, std::vector< ACG::ShaderModifier *> *_modifiers=0)
| Outputs the current render objects to the string. More...
void | setErrorDetectionLevel (int _level)
| Control error detection for checking render objects. More...
int | getErrorDetectionLevel () const
| Get error detection level.
void | setViewerID (int _viewerID)
| Set currently active viewer id. More...
void | setCoreProfileMode (bool _enable)
| Tell renderer to use core or compatibility profile. More...
const RenderObjectRange & | getCollectedSubtreeObjects () const

## Protected Member Functions
virtual void | prepareRenderingPipeline (ACG::GLState *_glState, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ACG::SceneGraph::BaseNode *_scenegraphRoot)
| Prepares renderer and OpenGL for any draw-related calls including. More...
virtual void | collectRenderObjects (ACG::GLState *_glState, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ACG::SceneGraph::BaseNode *_sceneGraphRoot)
| Traverse the scenegraph to collect render information. More...
void | traverseRenderableNodes (ACG::GLState *_glState, ACG::SceneGraph::DrawModes::DrawMode _drawMode, ACG::SceneGraph::BaseNode &_node, const ACG::SceneGraph::Material &_mat)
| Scene graph traversal for render object collection. More...
virtual void | sortRenderObjects ()
| Sort the renderobjects by priority. More...
virtual void | renderObject (ACG::RenderObject *_obj, GLSL::Program *_prog=0, bool _constRenderStates=false, const std::vector< unsigned int > *_shaderModifiers=0)
| Render one renderobject. More...
virtual void | bindObjectVBO (ACG::RenderObject *_obj, GLSL::Program *_prog)
| Binding VBOs (First state function) More...
virtual void | bindObjectUniforms (ACG::RenderObject *_obj, GLSL::Program *_prog)
| Binding Uniforms (Second state function) More...
virtual void | bindObjectRenderStates (ACG::RenderObject *_obj)
| Binding Render state (Third state function) More...
virtual void | drawObject (ACG::RenderObject *_obj)
| Executes the opengl draw call for one object (Fourth function) More...
virtual void | finishRenderingPipeline (bool _drawOverlay=true)
| Draw overlay objects and reset OpenGL state. More...
virtual void | saveInputFbo ()
| Save input Fbo configuration (fbo id + viewport)
virtual void | restoreInputFbo ()
| Restore the previously saved input Fbo configuration (fbo id + viewport)
virtual void | saveActiveFbo (GLint *_outFboId, GLint *_outViewport, GLint *_outDrawBuffer) const
| Save active Fbo configuration (fbo id + viewport) More...
virtual void | restoreFbo (GLint _fboId, const GLint *_outViewport, GLint _drawBuffer) const
| Restore a previously saved input Fbo configuration (fbo id + viewport) More...
virtual void | clearInputFbo (const ACG::Vec4f &_clearColor)
| Clear input Fbo. More...
virtual void | copyDepthToBackBuffer (GLuint _depthTex, float _scale=1.0f)
| Copy texture to depth buffer. More...
virtual void | renderDepthMap (int _viewerID, int _width, int _height)
| Render the depth map of the scene. More...
int | getNumRenderObjects () const
| Get the number of collected render objects (not including overlay objects or gl4.2 line objects)
int | getNumLights () const
| Get the number of current light sources.
ACG::RenderObject * | getRenderObject (int i)
| Get render objects in the sorted list by index (not including overlay objects)
ACG::RenderObject * | getOverlayRenderObject (int i)
| Get render objects in the sorted list by index (only overlay objects)
ACG::RenderObject * | getLineGL42RenderObject (int i)
| Get render objects in the sorted list by index (only line objects rendered with gl4.2)
LightData * | getLight (int i)
| Get light by index.
const ACG::Vec3f & | getGlobalAmbientScale () const
| Get global ambient light contribution from GL_LIGHT_MODEL_AMBIENT.
ACG::SceneGraph::BaseNode * | getRenderObjectNode (int i)
| Get node that emitted the render object in the sorted list by index (not including overlay objects)
ACG::SceneGraph::BaseNode * | getOverlayRenderObjectNode (int i)
| Get node that emitted the render object in the sorted list by index (only overlay objects)
void | setLineThicknessRenderingGL42 (bool _enable)

## Protected Attributes
int | numLights_
| Number of Lights.
LightData | lights_ [SG_MAX_SHADER_LIGHTS]
| Light sources ( Filled by addLight() )
ACG::Vec3f | globalLightModelAmbient_
std::vector< ACG::RenderObject > | renderObjects_
| array of renderobjects, filled by addRenderObject()
std::vector< int > | sortListObjects_
| map sortedID -> original renderObjectID
std::vector< int > | sortListOverlays_
| map sortedID -> original renderObjectID
std::vector< ACG::RenderObject * > | sortedObjects_
| sorted list of renderobjects without overlay objects (sorted in rendering order)
std::vector< ACG::RenderObject * > | overlayObjects_
| sorted list of overlay-only renderobjects (sorted in rendering order)
std::vector< ACG::RenderObjectModifier * > | renderObjectModifiers_
| active render object modifiers
std::vector< ACG::SceneGraph::BaseNode * > | renderObjectSource_
| source node that added the render object (map renderObjectID -> scenegraph node)
std::vector< ACG::SceneGraph::BaseNode * > | overlayObjectSource_
| source node that added the overlay render object (map renderObjectID -> scenegraph node)
std::map< int, ACG::FBO * > | depthMaps_
bool | depthMapUsed_
| true if at least one renderobject requires a scene depthmap, false otherwise
int | curViewerID_
| currently active viewer ID as specified in prepareRenderObjects()
GLMatrixf | viewMatrix_
| view transform
Vec3f | camPosWS_
| cam position in world-space
Vec3f | camDirWS_
| direction the camera is looking to in world-space
GLint | prevFbo_
| previous fbo
GLint | prevDrawBuffer_
| previous drawbuffer target (ie GL_BACK, GL_COLOR_ATTACHMENTi...)
GLint | prevViewport_ [4]
| previous viewport
bool | prevFboSaved_
| flag indicating a that saveCurrentFbo() has been called prior restoreFbo()
GLint | prevVAO_
| previously bound VAO
GLSL::Program * | depthCopyShader_
| shader copies depth of the first front layer to the back buffer
int | errorDetectionLevel_
| error-detection level for checking render objects
bool | coreProfile_
| core profile mode
RenderObjectRange | current_subtree_objects_

## Static Protected Attributes
static int | maxClipDistances_ = -1
| max number of clip distance outputs in a vertex shader

## Private Member Functions
void | renderLineThicknessGL42 ()

## Private Attributes
bool | enableLineThicknessGL42_
| Enable/disable gl4.2 based technique for rendering thick lines. More...
std::vector< RenderObject * > | lineGL42Objects_
| default line render objects that are rendered with gl4.2
std::map< int, Texture *> | lineColorBuffers_
| map from viewport id to line buffer

## Detailed Description

Definition at line 78 of file IRenderer.hh.

## Member Function Documentation

## ◆ addLight()

void ACG::IRenderer::addLight | ( | const LightData & | _light | ) |
| virtual

Callback for the scenegraph nodes, which send new lights to the renderer via this function.

Scenegraph nodes are able to add new light sources to the renderer with this function. To so, the node should implement getRenderObjects() and call addLight in there. LightNodes use this for example.

Parameters

  _light | Newly added light

Definition at line 1184 of file IRenderer.cc.

## ◆ addRenderObject()

void ACG::IRenderer::addRenderObject | ( | ACG::RenderObject * | _renderObject | ) |
| virtual

Callback for the scenegraph nodes, which send new render objects via this function.

AddRenderObject is typically called by a scenegraph nodes during the collection of renderable objects. A renderobject is a collection of opengl states, buffers and parameters, that correspond to exactly one draw call.

Creates another RenderObject instance internally, safe for temporary local RenderObject instances.

Note
  The VertexDeclaration address must be permanently valid.

Parameters

  _renderObject | Newly added render object

Reimplemented in DepthPeeling.

Definition at line 104 of file IRenderer.cc.

## ◆ addRenderObjectModifier()

void ACG::IRenderer::addRenderObjectModifier | ( | RenderObjectModifier * | _mod | ) |
| virtual

Callback for the scenegraph nodes, which adds a render object modifier to the renderer via this function.

This function is needed whenever a scenegraph node wants to set certain rendering parameters for all its child nodes. A scenegraph node does not have direct access to render object created within its subtree. Instead, it can implement a render object modifier and attach it to the renderer. This modifier is applied to all render objects added to this renderer until it gets removed again.

A good place to call this function is in the derived BaseNode::enter() function.

Parameters

  _mod | address of the modifier. It has to remain in memory until it gets removed from the renderer!

Definition at line 1198 of file IRenderer.cc.

## ◆ bindObjectRenderStates()

void ACG::IRenderer::bindObjectRenderStates | ( | ACG::RenderObject * | _obj | ) |
| protected virtual

Binding Render state (Third state function)

This is the third function called by renderObject().

Prepare the opengl state machine for a renderobject draw call.

This includes any glEnable/glDisable states, depth-cmp functions, blend equation..

Definition at line 1018 of file IRenderer.cc.

## ◆ bindObjectUniforms()

void ACG::IRenderer::bindObjectUniforms | ( | ACG::RenderObject * | _obj,
|  | GLSL::Program * | _prog
| ) |  |
| protected virtual

Binding Uniforms (Second state function)

This is the second function called by renderObject().

Set common shader constants like model-view-projection matrix, material colors and light params.

Definition at line 904 of file IRenderer.cc.

## ◆ bindObjectVBO()

void ACG::IRenderer::bindObjectVBO | ( | ACG::RenderObject * | _obj,
|  | GLSL::Program * | _prog
| ) |  |
| protected virtual

Binding VBOs (First state function)

This is the first function called by renderObject().

It binds vertex, index buffer and vertex format of a render object.

Definition at line 876 of file IRenderer.cc.

## ◆ clearInputFbo()

void ACG::IRenderer::clearInputFbo | ( | const ACG::Vec4f & | _clearColor | ) |
| protected virtual

Clear input Fbo.

Clears color and depth buffer of input Fbo (using a scissor test to only clear viewport area).

Parameters

  _clearColor | clear color

Definition at line 804 of file IRenderer.cc.

## ◆ collectRenderObjects()

void ACG::IRenderer::collectRenderObjects | ( | ACG::GLState * | _glState,
|  | ACG::SceneGraph::DrawModes::DrawMode | _drawMode,
|  | ACG::SceneGraph::BaseNode * | _sceneGraphRoot
| ) |  |
| protected virtual

Traverse the scenegraph to collect render information.

Traverses the scenegraph and calls the getRenderObject function of each node. Each node can then add multiple renderobjects via addRenderObject to this renderer.

Also collects all light sources in the scenegraph. The currently active list of renderobjects is invalidated too.

Definition at line 402 of file IRenderer.cc.

## ◆ copyDepthToBackBuffer()

void ACG::IRenderer::copyDepthToBackBuffer | ( | GLuint | _depthTex,
|  | float | _scale = `1.0f`
| ) |  |
| protected virtual

Copy texture to depth buffer.

Copies depth values from a texture to the input depth buffer. These are the changes made to the OpenGL state, which are not restored upon return:

- active texture stage is 0 with _depthTex bound
- internal shader program active
- internal screen quad vbo active
- filling mode is set to glPolygonMode(GL_FRONT, GL_FILL)

Parameters

  _depthTex | texture containing depth values
  _scale | scaling factor for the depth values from _depthTex

Definition at line 1348 of file IRenderer.cc.

## ◆ drawObject()

void ACG::IRenderer::drawObject | ( | ACG::RenderObject * | _obj | ) |
| protected virtual

Executes the opengl draw call for one object (Fourth function)

This is the fourth function called by renderObject().

Executes one draw call for the given render object

Definition at line 1083 of file IRenderer.cc.

## ◆ dumpCurrentRenderObjectsToString()

QString ACG::IRenderer::dumpCurrentRenderObjectsToString | ( | ACG::RenderObject ** | _list = `0`,
|  | bool | _outputShaders = `false`,
|  | std::vector< ACG::ShaderModifier *> * | _modifiers = `0`
| ) |  |
| virtual

Outputs the current render objects to the string.

Parameters

  _list | Pointer to a list of render objects used for output (defaults to unsorted internal list)
  _outputShaders | Output the shaders used for the objects?
  _modifiers | Pointer to vector of registered ShaderModifier

Returns
  Render object data in a QString

Definition at line 1283 of file IRenderer.cc.

## ◆ dumpRenderObjectsToFile()

void ACG::IRenderer::dumpRenderObjectsToFile | ( | const char * | _fileName,
|  | ACG::RenderObject ** | _sortedList = `0`
| ) |  | const

Debugging function to dump list of render objects into a file.

Dump list of render objects to text file.

Parameters

  _fileName | name of text file to write to
  _sortedList | dump sorted render objects in order, may be 0 to use the unsorted list instead

Definition at line 1264 of file IRenderer.cc.

## ◆ finishRenderingPipeline()

void ACG::IRenderer::finishRenderingPipeline | ( | bool | _drawOverlay = `true` | ) |
| protected virtual

Draw overlay objects and reset OpenGL state.

Optionally renders overlay objects. Resets critical OpenGL states to default to prevent crashes.

- deactivate framebuffer
- disable shaders
- disable vbo

Definition at line 667 of file IRenderer.cc.

## ◆ getCollectedSubtreeObjects()

const RenderObjectRange& ACG::IRenderer::getCollectedSubtreeObjects | ( |  | ) | const
| inline

During traversal of the scene graph this method returns the range of render objects that has been collected in the current subtree.

This method is exclusively intended to be called in the leave() function of scene graph nodes. Calling it from anywhere else will yield an undefined result with potentially invalid iterators.

Definition at line 493 of file IRenderer.hh.

## ◆ prepareRenderingPipeline()

void ACG::IRenderer::prepareRenderingPipeline | ( | ACG::GLState * | _glState,
|  | ACG::SceneGraph::DrawModes::DrawMode | _drawMode,
|  | ACG::SceneGraph::BaseNode * | _scenegraphRoot
| ) |  |
| protected virtual

Prepares renderer and OpenGL for any draw-related calls including.

Prepares renderer and OpenGL for any draw-related calls including:

- collecting renderobjects ( collectRenderObjects() )
- sorting renderobjects ( sortRenderObjects() )
- resetting OpenGL state machine for shader-based rendering

Parameters

  _glState | pointer to glstate
  _drawMode | default drawmode
  _scenegraphRoot | root node of scenegraph

Definition at line 532 of file IRenderer.cc.

## ◆ removeRenderObjectModifier()

void ACG::IRenderer::removeRenderObjectModifier | ( | RenderObjectModifier * | _mod | ) |
| virtual

Callback for the scenegraph nodes, which removes a render object modifier from the renderer.

Remove a previously added modifier. RenderObjects added to the renderer afterwards will not be affected anymore.

A good place to call this function is in the derived BaseNode::leave() function.

Parameters

  _mod | address of the modifier.

Definition at line 1203 of file IRenderer.cc.

## ◆ renderDepthMap()

void ACG::IRenderer::renderDepthMap | ( | int | _viewerID,
|  | int | _width,
|  | int | _height
| ) |  |
| protected virtual

Render the depth map of the scene.

When setting up a shader of a render-object, a scenegraph node can use the depth map for custom rendering techniques. If at least one render object calls this function, the depth map is later rendered before the scene pass. and bound to the shader of an renderobject in bindObjectUniforms according to the provided "depthMapUniformName". Depth Map format: GL_TEXTURE_2D, GL_R32F, depth value = gl_FragCoord.z This function is automatically called in prepareRenderingPipeline() when required.

Parameters

  _viewerID | id of viewport,
  _width | viewport width
  _height | viewport height

Definition at line 1431 of file IRenderer.cc.

## ◆ renderObject()

void ACG::IRenderer::renderObject | ( | ACG::RenderObject * | _obj,
|  | GLSL::Program * | _prog = `0`,
|  | bool | _constRenderStates = `false`,
|  | const std::vector< unsigned int > * | _shaderModifiers = `0`
| ) |  |
| protected virtual

Render one renderobject.

Fully prepares opengl for a renderobject and executes the draw call. This combines bindObjectVBO, bindObjectUniforms...

Optionally render-states may not be changed, in case depth-peeling or similar global shader operations may require a fixed state setting.

Shader modifiers can be combined and applied to this pass.

Definition at line 1140 of file IRenderer.cc.

## ◆ restoreFbo()

void ACG::IRenderer::restoreFbo | ( | GLint | _fboId,
|  | const GLint * | _outViewport,
|  | GLint | _drawBuffer
| ) |  | const
| protected virtual

Restore a previously saved input Fbo configuration (fbo id + viewport)

Parameters

  _fboId | fbo id
  _outViewport | [in] pointer to address of 4 GLint values receiving the currently active viewport
  _drawBuffer | draw-buffer target of fbo

Definition at line 797 of file IRenderer.cc.

## ◆ saveActiveFbo()

void ACG::IRenderer::saveActiveFbo | ( | GLint * | _outFboId,
|  | GLint * | _outViewport,
|  | GLint * | _outDrawBuffer
| ) |  | const
| protected virtual

Save active Fbo configuration (fbo id + viewport)

Parameters

  _outFboId | [out] pointer to address receiving the currently active fbo id
  _outViewport | [out] pointer to address of 4 GLint values receiving the currently active viewport
  _outDrawBuffer | [out] pointer to address receiving the currently active drawbuffer target (ie GL_BACK, GL_COLOR_ATTACHMENTi ..)

Definition at line 789 of file IRenderer.cc.

## ◆ setCoreProfileMode()

void ACG::IRenderer::setCoreProfileMode | ( | bool | _enable | ) |
| inline

Tell renderer to use core or compatibility profile.

Parameters

  _enable | renderer should use opengl in core profile mode

Definition at line 483 of file IRenderer.hh.

## ◆ setErrorDetectionLevel()

void ACG::IRenderer::setErrorDetectionLevel | ( | int | _level | ) |

Control error detection for checking render objects.

Levels: 0 - disable error detection 1 - fast check (obvious stuff that does not require much time to check) 2 - intensive check (do additional check, possibly false positives and impact on performance)

Default level is 1

Parameters

  _level | detection level

Definition at line 1700 of file IRenderer.cc.

## ◆ setLineThicknessRenderingGL42()

void ACG::IRenderer::setLineThicknessRenderingGL42 | ( | bool | _enable | ) |
| protected

Enable/disable line thickness rendering with opengl4.2

Instead of quad extrusion in a geometry shader, thick lines are manually rasterized in a load/store image. This image is then composited with the back buffer. If the gpu does not support image load/store, the default quad extrusion is used anyway and this function has no effect.

Parameters

  _enable | enable/disable

Definition at line 1694 of file IRenderer.cc.

## ◆ setViewerID()

void ACG::IRenderer::setViewerID | ( | int | _viewerID | ) |

Set currently active viewer id.

If the scenegraph makes use of the z-prepass feature and the application uses multiple viewports, the currently active viewport should be set prior rendering. Otherwise, this function can be ignored.

Parameters

  _viewerID | unique id of the current viewport (i.e. ViewerProperties::viewerID() )

Definition at line 1519 of file IRenderer.cc.

## ◆ sortRenderObjects()

void ACG::IRenderer::sortRenderObjects | ( |  | ) |
| protected virtual

Sort the renderobjects by priority.

Sort array of renderobjects by priority and store the result in sortedObjects_.

Definition at line 839 of file IRenderer.cc.

## ◆ traverseRenderableNodes()

void ACG::IRenderer::traverseRenderableNodes | ( | ACG::GLState * | _glState,
|  | ACG::SceneGraph::DrawModes::DrawMode | _drawMode,
|  | ACG::SceneGraph::BaseNode & | _node,
|  | const ACG::SceneGraph::Material & | _mat
| ) |  |
| protected

Scene graph traversal for render object collection.

Calls getRenderObjects on each node of the scenegraph recursively.Calls getRenderObjects on each node of the scenegraph recursively. Each node then triggers the callbacks.

Definition at line 447 of file IRenderer.cc.

## Member Data Documentation

## ◆ depthMaps_

std::map<int, ACG::FBO*> ACG::IRenderer::depthMaps_
| protected

Stores fbo containing a depth map for each viewport. The depth map is computed in a z-prepass if at least one RenderObject makes use of the scene depth map. (optional convenience feature)

Definition at line 536 of file IRenderer.hh.

## ◆ enableLineThicknessGL42_

bool ACG::IRenderer::enableLineThicknessGL42_
| private

Enable/disable gl4.2 based technique for rendering thick lines.

If enabled, default line objects are not returned via getRenderObject(), but are rendered in finishRenderingPipeline() just before drawing overlays.

Definition at line 594 of file IRenderer.hh.

## ◆ globalLightModelAmbient_

ACG::Vec3f ACG::IRenderer::globalLightModelAmbient_
| protected

ambient color scale for global light: this is set via glLightModel(GL_LIGHT_MODEL_AMBIENT, scale)

Definition at line 506 of file IRenderer.hh.

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

- OpenFlipper/libs_required/ACG/GL/IRenderer.hh
- OpenFlipper/libs_required/ACG/GL/IRenderer.cc