Developer Documentation
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() More...
 
void addTexture (const Texture &_t, const size_t _stage, bool _addToShaderGen=true)
 
void clearTextures ()
 clear all textures. Also affected on shaderDesc More...
 
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. More...
 
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. More...
 
void resetLineRendering ()
 Reset shader template names blocked by line rendering. More...
 
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. More...
 
void resetPointRendering ()
 Reset shader template names blocked by point rendering. More...
 
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. More...
 
GLMatrixd proj
 Projection transform. More...
 
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 .. More...
 
GLenum alphaFunc
 GL_LESS, GL_LEQUAL, GL_GREATER .. More...
 
float alphaRef
 
GLenum blendSrc
 
GLenum blendDest
 glBlendFunc: GL_SRC_ALPHA, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ... More...
 
Vec2f depthRange
 glDepthRange: (znear, zmax) More...
 
GLuint clipDistanceMask
 
bool programPointSize
 
float pointSize
 
Vec2f patchDefaultInnerLevel
 
Vec4f patchDefaultOuterLevel
 
Vec3f diffuse
 material definitions More...
 
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 More...
 
std::string debugName
 
unsigned int internalFlags_
 may be used internally by the renderer More...
 
Geometry definition
GLuint vertexArrayObject
 Use vertex array object. More...
 
GLuint vertexBuffer
 VBO, IBO ids, ignored if VAO is provided. More...
 
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 More...
 
unsigned int numIndices
 Number indices to render. More...
 
unsigned int indexOffset
 Offset to first index in the index buffer or vertex buffer respectively. More...
 
GLenum indexType
 Index element type. More...
 
GLsizei numInstances
 
const VertexDeclarationvertexDecl
 Defines the vertex buffer layout, ignored if VAO is provided. More...
 

Private Attributes

std::map< size_t, Texturetextures_
 holds the textures (second) and the stage id (first) More...
 
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.

◆ ~RenderObject()

ACG::RenderObject::~RenderObject ( )

Definition at line 235 of file RenderObject.cc.

Member Function Documentation

◆ addTexture() [1/2]

void ACG::RenderObject::addTexture ( const Texture _t)
inline

adds a texture to stage RenderObjects::numTextures()

Definition at line 326 of file RenderObject.hh.

◆ addTexture() [2/2]

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
_poolinput pool

Definition at line 458 of file RenderObject.cc.

◆ clearTextures()

void ACG::RenderObject::clearTextures ( )
inline

clear all textures. Also affected on shaderDesc

Definition at line 347 of file RenderObject.hh.

◆ glAlphaFunc()

void ACG::RenderObject::glAlphaFunc ( GLenum  func,
float  ref 
)
inline

Definition at line 416 of file RenderObject.hh.

◆ glBindBuffer()

void ACG::RenderObject::glBindBuffer ( GLenum  target,
GLuint  buffer 
)
inline

Definition at line 370 of file RenderObject.hh.

◆ glColorMask()

void ACG::RenderObject::glColorMask ( GLboolean  r,
GLboolean  g,
GLboolean  b,
GLboolean  a 
)
inline

Definition at line 411 of file RenderObject.hh.

◆ glDrawArrays()

void ACG::RenderObject::glDrawArrays ( GLenum  mode,
GLint  first,
GLsizei  count 
)
inline

Definition at line 379 of file RenderObject.hh.

◆ glDrawElements()

void ACG::RenderObject::glDrawElements ( GLenum  mode,
GLsizei  count,
GLenum  type,
const GLvoid *  indices 
)
inline

Definition at line 395 of file RenderObject.hh.

◆ glDrawElementsInstanced()

void ACG::RenderObject::glDrawElementsInstanced ( GLenum  mode,
GLsizei  count,
GLenum  type,
const GLvoid *  indices,
GLsizei  primcount 
)
inline

Definition at line 400 of file RenderObject.hh.

◆ glDrawInstancedArrays()

void ACG::RenderObject::glDrawInstancedArrays ( GLenum  mode,
GLint  first,
GLsizei  count,
GLsizei  primcount 
)
inline

Definition at line 384 of file RenderObject.hh.

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

◆ isDefaultLineObject()

bool ACG::RenderObject::isDefaultLineObject ( ) const

Test if the object is rendered with one of the default line thickness methods.

Definition at line 472 of file RenderObject.cc.

◆ isDefaultPointObject()

bool ACG::RenderObject::isDefaultPointObject ( ) const

Test if the object is rendered with one of the default point extension methods.

Definition at line 493 of file RenderObject.cc.

◆ numTextures()

size_t ACG::RenderObject::numTextures ( )
inline

Definition at line 351 of file RenderObject.hh.

◆ resetLineRendering()

void ACG::RenderObject::resetLineRendering ( )

Reset shader template names blocked by line rendering.

Definition at line 479 of file RenderObject.cc.

◆ resetPointRendering()

void ACG::RenderObject::resetPointRendering ( )

Reset shader template names blocked by point rendering.

Definition at line 499 of file RenderObject.cc.

◆ setMaterial()

void ACG::RenderObject::setMaterial ( const SceneGraph::Material _mat)

Definition at line 178 of file RenderObject.cc.

◆ setUniform() [1/8]

void ACG::RenderObject::setUniform ( const char *  _name,
const ACG::GLMatrixf _value,
bool  _transposed = false 
)

Definition at line 438 of file RenderObject.cc.

◆ setUniform() [2/8]

void 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

Definition at line 423 of file RenderObject.cc.

◆ setUniform() [3/8]

void 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

Definition at line 428 of file RenderObject.cc.

◆ setUniform() [4/8]

void 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

Definition at line 433 of file RenderObject.cc.

◆ setUniform() [5/8]

void ACG::RenderObject::setUniform ( const char *  _name,
GLfloat *  _values,
int  _count 
)

Definition at line 453 of file RenderObject.cc.

◆ setUniform() [6/8]

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

set values for float uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type

Definition at line 418 of file RenderObject.cc.

◆ setUniform() [7/8]

void ACG::RenderObject::setUniform ( const char *  _name,
GLint *  _values,
int  _count 
)

Definition at line 448 of file RenderObject.cc.

◆ setUniform() [8/8]

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

set values for int uniforms

Parameters
_nameName of uniform in shader
_valuevalue of the type

Definition at line 413 of file RenderObject.cc.

◆ setUniformMat3()

void ACG::RenderObject::setUniformMat3 ( const char *  _name,
const ACG::GLMatrixf _value,
bool  _transposed = false 
)

Definition at line 443 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.

◆ setupShaderGenFromDrawmode()

void ACG::RenderObject::setupShaderGenFromDrawmode ( const SceneGraph::DrawModes::DrawModeProperties _props)

Fills out ShaderGenDesc parameters based on Drawmode properties.

Definition at line 137 of file RenderObject.cc.

◆ textures()

const std::map< size_t, Texture > & ACG::RenderObject::textures ( )
inline

Definition at line 349 of file RenderObject.hh.

◆ toString()

QString ACG::RenderObject::toString ( ) const

Returns a text representation of the RenderObject for debugging purposes.

Definition at line 239 of file RenderObject.cc.

Friends And Related Function Documentation

◆ IRenderer

friend class IRenderer
friend

Definition at line 100 of file RenderObject.hh.

Member Data Documentation

◆ alpha

float ACG::RenderObject::alpha

Definition at line 279 of file RenderObject.hh.

◆ alphaFunc

GLenum ACG::RenderObject::alphaFunc

GL_LESS, GL_LEQUAL, GL_GREATER ..

Definition at line 243 of file RenderObject.hh.

◆ alphaRef

float ACG::RenderObject::alphaRef

Definition at line 244 of file RenderObject.hh.

◆ alphaTest

bool ACG::RenderObject::alphaTest

Definition at line 231 of file RenderObject.hh.

◆ ambient

Vec3f ACG::RenderObject::ambient

Definition at line 275 of file RenderObject.hh.

◆ blendDest

GLenum ACG::RenderObject::blendDest

glBlendFunc: GL_SRC_ALPHA, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ...

Definition at line 247 of file RenderObject.hh.

◆ blending

bool ACG::RenderObject::blending

Definition at line 230 of file RenderObject.hh.

◆ blendSrc

GLenum ACG::RenderObject::blendSrc

Definition at line 247 of file RenderObject.hh.

◆ clipDistanceMask

GLuint ACG::RenderObject::clipDistanceMask

Definition at line 255 of file RenderObject.hh.

◆ colorWriteMask

GLboolean ACG::RenderObject::colorWriteMask[4]

Definition at line 237 of file RenderObject.hh.

◆ culling

bool ACG::RenderObject::culling

Definition at line 229 of file RenderObject.hh.

◆ debugID

int ACG::RenderObject::debugID

used internally for renderer debugging

Definition at line 360 of file RenderObject.hh.

◆ debugName

std::string ACG::RenderObject::debugName

Definition at line 361 of file RenderObject.hh.

◆ depthFunc

GLenum ACG::RenderObject::depthFunc

GL_LESS, GL_LEQUAL, GL_GREATER ..

Definition at line 240 of file RenderObject.hh.

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

◆ depthRange

Vec2f ACG::RenderObject::depthRange

glDepthRange: (znear, zmax)

Definition at line 249 of file RenderObject.hh.

◆ depthTest

bool ACG::RenderObject::depthTest

Definition at line 232 of file RenderObject.hh.

◆ depthWrite

bool ACG::RenderObject::depthWrite

Definition at line 233 of file RenderObject.hh.

◆ diffuse

Vec3f ACG::RenderObject::diffuse

material definitions

Definition at line 274 of file RenderObject.hh.

◆ emissive

Vec3f ACG::RenderObject::emissive

Definition at line 277 of file RenderObject.hh.

◆ fillMode

GLenum ACG::RenderObject::fillMode

Definition at line 235 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 163 of file RenderObject.hh.

◆ indexOffset

unsigned int ACG::RenderObject::indexOffset

Offset to first index in the index buffer or vertex buffer respectively.

Definition at line 191 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.

◆ internalFlags_

unsigned int ACG::RenderObject::internalFlags_

may be used internally by the renderer

Definition at line 364 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.

◆ modelview

GLMatrixd ACG::RenderObject::modelview

Modelview transform.

Definition at line 138 of file RenderObject.hh.

◆ name

std::string ACG::RenderObject::name

Name for logging.

Definition at line 121 of file RenderObject.hh.

◆ numIndices

unsigned int ACG::RenderObject::numIndices

Number indices to render.

Definition at line 188 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.

◆ patchDefaultInnerLevel

Vec2f ACG::RenderObject::patchDefaultInnerLevel

Definition at line 269 of file RenderObject.hh.

◆ patchDefaultOuterLevel

Vec4f ACG::RenderObject::patchDefaultOuterLevel

Definition at line 270 of file RenderObject.hh.

◆ patchVertices

unsigned int ACG::RenderObject::patchVertices

patch size if primitiveMode is GL_PATCHES for rendering with tessellation shaders

Definition at line 185 of file RenderObject.hh.

◆ pointSize

float ACG::RenderObject::pointSize

Definition at line 263 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.

◆ programPointSize

bool ACG::RenderObject::programPointSize

Definition at line 260 of file RenderObject.hh.

◆ proj

GLMatrixd ACG::RenderObject::proj

Projection transform.

Definition at line 141 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.

◆ shininess

float ACG::RenderObject::shininess

Definition at line 280 of file RenderObject.hh.

◆ specular

Vec3f ACG::RenderObject::specular

Definition at line 276 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.

◆ textures_

std::map<size_t,Texture> ACG::RenderObject::textures_
private

holds the textures (second) and the stage id (first)

Definition at line 355 of file RenderObject.hh.

◆ uniformPool_

GLSL::UniformPool ACG::RenderObject::uniformPool_
private

Definition at line 529 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.

◆ vertexBuffer

GLuint ACG::RenderObject::vertexBuffer

VBO, IBO ids, ignored if VAO is provided.

Definition at line 162 of file RenderObject.hh.

◆ vertexDecl

const VertexDeclaration* ACG::RenderObject::vertexDecl

Defines the vertex buffer layout, ignored if VAO is provided.

Definition at line 208 of file RenderObject.hh.


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