Developer Documentation
ACG::SceneGraph::ACG::RenderObject Struct Reference

Interface class between scenegraph and renderer. More...

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...
 
 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
 
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
 
const char * 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 VertexDeclarationvertexDecl
 Defines the vertex buffer layout, ignored if VAO is provided.
 

Private Attributes

std::map< size_t, Texturetextures_
 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 105 of file MeshNode2T.cc.

Constructor & Destructor Documentation

ACG::SceneGraph::ACG::RenderObject::RenderObject ( )

default constructor set all members to OpenGL default values

ACG::SceneGraph::ACG::RenderObject::RenderObject ( )

default constructor set all members to OpenGL default values

Member Function Documentation

void ACG::SceneGraph::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 333 of file MeshNode2T.cc.

void ACG::SceneGraph::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 333 of file MeshNode2T.cc.

void ACG::SceneGraph::ACG::RenderObject::addUniformPool ( const GLSL::UniformPool _pool)

add all uniforms from a pool

Parameters
_poolinput pool
void ACG::SceneGraph::ACG::RenderObject::addUniformPool ( const GLSL::UniformPool _pool)

add all uniforms from a pool

Parameters
_poolinput pool
void ACG::SceneGraph::ACG::RenderObject::initFromState ( GLState _glState)

Initializes a RenderObject instance.

Grabs material and transforms automatically if a GLState is provided.

void ACG::SceneGraph::ACG::RenderObject::initFromState ( GLState _glState)

Initializes a RenderObject instance.

Grabs material and transforms automatically if a GLState is provided.

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

set values for int uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
GLint  _value 
)

set values for int uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
GLfloat  _value 
)

set values for float uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
GLfloat  _value 
)

set values for float uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
const ACG::Vec2f _value 
)

set values for Vec2f uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
const ACG::Vec2f _value 
)

set values for Vec2f uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
const ACG::Vec3f _value 
)

set values for Vec3f uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
const ACG::Vec3f _value 
)

set values for Vec3f uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
const ACG::Vec4f _value 
)

set values for Vec4f uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::ACG::RenderObject::setUniform ( const char *  _name,
const ACG::Vec4f _value 
)

set values for Vec4f uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type
void ACG::SceneGraph::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

void ACG::SceneGraph::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

void ACG::SceneGraph::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

void ACG::SceneGraph::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

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

Returns a text representation of the RenderObject for debugging purposes.

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

Returns a text representation of the RenderObject for debugging purposes.

Member Data Documentation

const char * ACG::SceneGraph::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 301 of file MeshNode2T.cc.

GLuint ACG::SceneGraph::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 169 of file MeshNode2T.cc.

GLenum ACG::SceneGraph::ACG::RenderObject::indexType

Index element type.

Has to be GL_UNSIGNED_SHORT or GL_UNSIGNED_INT

Definition at line 204 of file MeshNode2T.cc.

bool ACG::SceneGraph::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 290 of file MeshNode2T.cc.

std::string ACG::SceneGraph::ACG::RenderObject::name

Name for logging.

Definition at line 128 of file MeshNode2T.cc.

GLsizei ACG::SceneGraph::ACG::RenderObject::numInstances

\ brief Instancing

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

Definition at line 211 of file MeshNode2T.cc.

bool ACG::SceneGraph::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 142 of file MeshNode2T.cc.

GLenum ACG::SceneGraph::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 189 of file MeshNode2T.cc.

int ACG::SceneGraph::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 123 of file MeshNode2T.cc.

ShaderGenDesc ACG::SceneGraph::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 232 of file MeshNode2T.cc.

const void * ACG::SceneGraph::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 180 of file MeshNode2T.cc.

GLuint ACG::SceneGraph::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 165 of file MeshNode2T.cc.


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