Developer Documentation

Classes | Public Member Functions | Public Attributes | Private Attributes | Friends | List of all members
ACG::RenderObject Struct Reference

Interface class between scenegraph and renderer. More...

`#include <OpenFlipper/libs_required/ACG/GL/RenderObject.hh>`

## Classes
struct | Texture
| Texture to be used. More...

## Public Member Functions
| RenderObject ()
void | addTexture (const Texture &_t)
| adds a texture to stage RenderObjects::numTextures()
void | addTexture (const Texture &_t, const size_t _stage, bool _addToShaderGen=true)
void | clearTextures ()
| clear all textures. Also affected on shaderDesc
const std::map< size_t, Texture > & | textures ()
size_t | numTextures ()
void | glBindBuffer (GLenum target, GLuint buffer)
void | glDrawArrays (GLenum mode, GLint first, GLsizei count)
void | glDrawInstancedArrays (GLenum mode, GLint first, GLsizei count, GLsizei primcount)
void | glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
void | glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount)
void | glColorMask (GLboolean r, GLboolean g, GLboolean b, GLboolean a)
void | glAlphaFunc (GLenum func, float ref)
void | initFromState (GLState *_glState)
| Initializes a RenderObject instance. More...
void | setMaterial (const SceneGraph::Material *_mat)
void | setupShaderGenFromDrawmode (const SceneGraph::DrawModes::DrawModeProperties *_props)
| Fills out ShaderGenDesc parameters based on Drawmode properties.
void | setupLineRendering (float _lineWidth, const Vec2f &_screenSize)
| Setup rendering of thick lines. More...
bool | isDefaultLineObject () const
| Test if the object is rendered with one of the default line thickness methods.
void | resetLineRendering ()
| Reset shader template names blocked by line rendering.
void | setupPointRendering (float _pointSize, const Vec2f &_screenSize)
| Setup rendering of circle points. More...
bool | isDefaultPointObject () const
| Test if the object is rendered with one of the default point extension methods.
void | resetPointRendering ()
| Reset shader template names blocked by point rendering.
QString | toString () const
void | setUniform (const char *_name, GLint _value)
| set values for int uniforms More...
void | setUniform (const char *_name, GLfloat _value)
| set values for float uniforms More...
void | setUniform (const char *_name, const ACG::Vec2f &_value)
| set values for Vec2f uniforms More...
void | setUniform (const char *_name, const ACG::Vec3f &_value)
| set values for Vec3f uniforms More...
void | setUniform (const char *_name, const ACG::Vec4f &_value)
| set values for Vec4f uniforms More...
void | setUniform (const char *_name, const ACG::GLMatrixf &_value, bool _transposed=false)
void | setUniformMat3 (const char *_name, const ACG::GLMatrixf &_value, bool _transposed=false)
void | setUniform (const char *_name, GLint *_values, int _count)
void | setUniform (const char *_name, GLfloat *_values, int _count)
void | addUniformPool (const GLSL::UniformPool &_pool)
| add all uniforms from a pool More...

## Public Attributes
int | priority
| Priority to allow sorting of objects. More...
std::string | name
| Name for logging. More...
bool | overlay
| Layer based rendering. More...
GLMatrixd | modelview
| Modelview transform.
GLMatrixd | proj
| Projection transform.
ShaderGenDesc | shaderDesc
| Drawmode and other shader params. More...
bool | culling
bool | blending
bool | alphaTest
bool | depthTest
bool | depthWrite
GLenum | fillMode
GLboolean | colorWriteMask [4]
GLenum | depthFunc
| GL_LESS, GL_LEQUAL, GL_GREATER ..
GLenum | alphaFunc
| GL_LESS, GL_LEQUAL, GL_GREATER ..
float | alphaRef
GLenum | blendSrc
GLenum | blendDest
| glBlendFunc: GL_SRC_ALPHA, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ...
Vec2f | depthRange
| glDepthRange: (znear, zmax)
GLuint | clipDistanceMask
bool | programPointSize
float | pointSize
Vec2f | patchDefaultInnerLevel
Vec4f | patchDefaultOuterLevel
Vec3f | diffuse
| material definitions
Vec3f | ambient
Vec3f | specular
Vec3f | emissive
float | alpha
float | shininess
bool | inZPrePass
| Specify whether this object should be rendered in a z-prepass. More...
const char * | depthMapUniformName
| Uniform name of the depth map in the used shader. More...
int | debugID
| used internally for renderer debugging
std::string | debugName
unsigned int | internalFlags_
| may be used internally by the renderer
Geometry definition
GLuint | vertexArrayObject
| Use vertex array object. More...
GLuint | vertexBuffer
| VBO, IBO ids, ignored if VAO is provided.
GLuint | indexBuffer
| Use vertex array object. More...
const void * | sysmemIndexBuffer
| Use system memory index buffer. More...
GLenum | primitiveMode
| Primitive type. More...
unsigned int | patchVertices
| patch size if primitiveMode is GL_PATCHES for rendering with tessellation shaders
unsigned int | numIndices
| Number indices to render.
unsigned int | indexOffset
| Offset to first index in the index buffer or vertex buffer respectively.
GLenum | indexType
| Index element type. More...
GLsizei | numInstances
const VertexDeclaration * | vertexDecl
| Defines the vertex buffer layout, ignored if VAO is provided.

## Private Attributes
std::map< size_t, Texture > | textures_
| holds the textures (second) and the stage id (first)
GLSL::UniformPool | uniformPool_

## Friends
class | IRenderer

## Detailed Description

Interface class between scenegraph and renderer.

RenderObject is the primary interface between scenegraph and renderer.

Scenegraph nodes have to declare any renderable geometry objects by providing:

- geometry type (triangles, lines, points, triangle strips, ...)
- geometry buffers (vertex/index buffers, vbo, ibo, sysmem and non-indexed supported )
- vertex buffer layout ( via vertex declaration, eventually declare sysmem vertex buffer here )
- draw mode
- OpenGL render states
- material properties
- texture

Quick initialization for default values is recommended. RenderObject::initFromState() grabs transforms, material and render states from a GLState.

An OpenGL style interface for geometry setup is available via: RenderObject::glBindBuffer() RenderObject::glDrawArrays() RenderObject::glDrawArrayElements()

You still have to create the VertexDeclaration on your own first though.

Note that each RenderObject corresponds to exactly one deferred draw call.

Definition at line 98 of file RenderObject.hh.

## Constructor & Destructor Documentation

## ◆ RenderObject()

ACG::RenderObject::RenderObject | ( |  | ) |

default constructor set all members to OpenGL default values

Definition at line 197 of file RenderObject.cc.

## Member Function Documentation

## ◆ addTexture()

void ACG::RenderObject::addTexture | ( | const Texture & | _t,
|  | const size_t | _stage,
|  | bool | _addToShaderGen = `true`
| ) |  |
| inline

adds a texture to an specific stage and enables texture support in shaderDesc

Definition at line 334 of file RenderObject.hh.

## ◆ addUniformPool()

void ACG::RenderObject::addUniformPool | ( | const GLSL::UniformPool & | _pool | ) |

add all uniforms from a pool

Parameters

  _pool | input pool

Definition at line 458 of file RenderObject.cc.

## ◆ initFromState()

void ACG::RenderObject::initFromState | ( | GLState * | _glState | ) |

Initializes a RenderObject instance.

Grabs material and transforms automatically if a GLState is provided.

Definition at line 61 of file RenderObject.cc.

## ◆ setUniform() [1/5]

void ACG::RenderObject::setUniform | ( | const char * | _name,
|  | GLint | _value
| ) |  |

set values for int uniforms

Parameters

  _name | Name of uniform in shader
  _value | value of the type

Definition at line 413 of file RenderObject.cc.

## ◆ setUniform() [2/5]

void ACG::RenderObject::setUniform | ( | const char * | _name,
|  | GLfloat | _value
| ) |  |

set values for float uniforms

Parameters

  _name | Name of uniform in shader
  _value | value of the type

Definition at line 418 of file RenderObject.cc.

## ◆ setUniform() [3/5]

void ACG::RenderObject::setUniform | ( | const char * | _name,
|  | const ACG::Vec2f & | _value
| ) |  |

set values for Vec2f uniforms

Parameters

  _name | Name of uniform in shader
  _value | value of the type

Definition at line 423 of file RenderObject.cc.

## ◆ setUniform() [4/5]

void ACG::RenderObject::setUniform | ( | const char * | _name,
|  | const ACG::Vec3f & | _value
| ) |  |

set values for Vec3f uniforms

Parameters

  _name | Name of uniform in shader
  _value | value of the type

Definition at line 428 of file RenderObject.cc.

## ◆ setUniform() [5/5]

void ACG::RenderObject::setUniform | ( | const char * | _name,
|  | const ACG::Vec4f & | _value
| ) |  |

set values for Vec4f uniforms

Parameters

  _name | Name of uniform in shader
  _value | value of the type

Definition at line 433 of file RenderObject.cc.

## ◆ setupLineRendering()

void ACG::RenderObject::setupLineRendering | ( | float | _lineWidth,
|  | const Vec2f & | _screenSize
| ) |  |

Setup rendering of thick lines.

Two default rendering methods for line thickness are available:

- quad extrusion in geometry shader (anti-aliasing, clipping issue due to depth testing with scene)
- manual rasterization via shader image load/store (no anti-aliasing, no clipping issue, requires gl4.2) The method used depends on renderer settings.

Also, this will overwrite the geometry and fragment shader template. Requires support for geometry shaders with glsl 150

Definition at line 464 of file RenderObject.cc.

## ◆ setupPointRendering()

void ACG::RenderObject::setupPointRendering | ( | float | _pointSize,
|  | const Vec2f & | _screenSize
| ) |  |

Setup rendering of circle points.

Use default quad extrusion shader. This will overwrite geometry and fragment shader template. Requires support for geometry shaders with glsl 150

Definition at line 484 of file RenderObject.cc.

## ◆ toString()

QString ACG::RenderObject::toString | ( |  | ) | const

Returns a text representation of the RenderObject for debugging purposes.

Definition at line 239 of file RenderObject.cc.

## Member Data Documentation

## ◆ depthMapUniformName

const char* ACG::RenderObject::depthMapUniformName

Uniform name of the depth map in the used shader.

If a shader used by this object requires a depth map of the scene, you can specify the name of the texture sampler uniform used here. This depth map is automatically computed in a z-prepass of the scene later in the renderer and assigned to the shader. It will be a 2D texture storing the values of the depth buffer (gl_FragCoord.z) in GL_TEXTURE_2D, GL_R32F format. Should be set to 0 if the used shader does not require a depth map.

default: 0

Definition at line 302 of file RenderObject.hh.

## ◆ indexBuffer

GLuint ACG::RenderObject::indexBuffer

Use vertex array object.

Optionally, a VAO can be used to setup rendering buffers and attribute locations. If this is 0 (default), vertex-buffer, index-buffer, vertex-declarition etc. have to be provided individually. Otherwise, the VAO is used instead of vertexBuffer, indexBuffer etc. In this case, it is not neccessary to specify a vertex-declaration and provide vertex- and indexbuffer. This is also the only way to setup a renderobject that makes use of multiple vertexbuffers!

Definition at line 162 of file RenderObject.hh.

## ◆ indexType

GLenum ACG::RenderObject::indexType

Index element type.

Has to be GL_UNSIGNED_SHORT or GL_UNSIGNED_INT

Definition at line 197 of file RenderObject.hh.

## ◆ inZPrePass

bool ACG::RenderObject::inZPrePass

Specify whether this object should be rendered in a z-prepass.

The renderer might do a z-prepass for some rendering techniques. You can control whether an object should be taken into account for a z-prepass or not. For instance, scene objects should be rendered in the z-prepass, but overlays (coordsys, selection stuff..) should not.

default: true

Definition at line 291 of file RenderObject.hh.

## ◆ name

std::string ACG::RenderObject::name

Name for logging.

Definition at line 121 of file RenderObject.hh.

## ◆ numInstances

GLsizei ACG::RenderObject::numInstances

\ brief Instancing

Number of instances to render. numinstances <= 0, disables instancing.

Definition at line 204 of file RenderObject.hh.

## ◆ overlay

bool ACG::RenderObject::overlay

Layer based rendering.

The renderer currently supports two layers:

- scene layer
- overlay layer

Usually a render plugin operates on the scene layer only and overlayed objects are rendered on top of the result. For instance, meshes are rendered in the scene layer while coordsys objects are overlayed.

Note
  default = false

Definition at line 135 of file RenderObject.hh.

## ◆ primitiveMode

GLenum ACG::RenderObject::primitiveMode

Primitive type.

PrimitiveType must be one of the following: GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_QUAD_STRIP, GL_QUADS, GL_POLYGON, GL_TRIANGLES_ADJACENCY, GL_LINES_ADJACENCY, GL_PATCHES

Definition at line 182 of file RenderObject.hh.

## ◆ priority

int ACG::RenderObject::priority

Priority to allow sorting of objects.

The renderer sorts objects based on priority in ascending order before rendering.

Note
  negative values allowed

Definition at line 116 of file RenderObject.hh.

## ◆ shaderDesc

ShaderGenDesc ACG::RenderObject::shaderDesc

Drawmode and other shader params.

- setup the shade mode : shaderDesc.shadeMode = .. (necessary)
- enable lighting with all lights in the scene: shaderDesc.numLights = 0 (recommended)
- disable lighting(only removes lighting code): shaderDesc.numLights = -1
- manual lighting setup: shaderDesc.numLights = n shaderDesc.lightTypes[i] = ..
- enable / disable texturing : shaderDesc.textured = .. ...

Definition at line 225 of file RenderObject.hh.

## ◆ sysmemIndexBuffer

const void* ACG::RenderObject::sysmemIndexBuffer

Use system memory index buffer.

If you don't want to use an IBO, simply assign your sysmem indexbuffer address here. If both indexBuffer and sysmemIndexBuffer are 0, the renderer will treat this RenderObject like an unfolded vertex buffer (e.g. 3 * nTris vertex buffer for GL_TRIANGLES)

Note
  It is also possible to specify a sysmem vertex buffer by setting up the VertexDeclaration accordingly use numIndices

Definition at line 173 of file RenderObject.hh.

## ◆ vertexArrayObject

GLuint ACG::RenderObject::vertexArrayObject

Use vertex array object.

Optionally, a VAO can be used to setup rendering buffers and attribute locations. If this is 0 (default), vertex-buffer, index-buffer, vertex-declarition etc. have to be provided individually. Otherwise, the VAO is used instead of vertexBuffer, indexBuffer etc. In this case, it is not neccessary to specify a vertex-declaration and provide vertex- and indexbuffer. This is also the only way to setup a renderobject that makes use of multiple vertexbuffers!

Definition at line 158 of file RenderObject.hh.

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

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