Developer Documentation
|
Interface class between scenegraph and renderer. More...
#include <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 |
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 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 |
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:
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 RenderObject.hh.
ACG::RenderObject::RenderObject | ( | ) |
default constructor set all members to OpenGL default values
Definition at line 191 of file RenderObject.cc.
|
inline |
adds a texture to an specific stage and enables texture support in shaderDesc
Definition at line 333 of file RenderObject.hh.
void ACG::RenderObject::addUniformPool | ( | const GLSL::UniformPool & | _pool | ) |
add all uniforms from a pool
_pool | input pool |
Definition at line 443 of file RenderObject.cc.
void ACG::RenderObject::initFromState | ( | GLState * | _glState | ) |
Initializes a RenderObject instance.
Grabs material and transforms automatically if a GLState is provided.
Definition at line 69 of file RenderObject.cc.
void ACG::RenderObject::setUniform | ( | const char * | _name, |
GLint | _value | ||
) |
set values for int uniforms
_name | Name of uniform in shader |
_value | value of the type |
Definition at line 398 of file RenderObject.cc.
void ACG::RenderObject::setUniform | ( | const char * | _name, |
GLfloat | _value | ||
) |
set values for float uniforms
_name | Name of uniform in shader |
_value | value of the type |
Definition at line 403 of file RenderObject.cc.
void ACG::RenderObject::setUniform | ( | const char * | _name, |
const ACG::Vec2f & | _value | ||
) |
set values for Vec2f uniforms
_name | Name of uniform in shader |
_value | value of the type |
Definition at line 408 of file RenderObject.cc.
void ACG::RenderObject::setUniform | ( | const char * | _name, |
const ACG::Vec3f & | _value | ||
) |
set values for Vec3f uniforms
_name | Name of uniform in shader |
_value | value of the type |
Definition at line 413 of file RenderObject.cc.
void ACG::RenderObject::setUniform | ( | const char * | _name, |
const ACG::Vec4f & | _value | ||
) |
set values for Vec4f uniforms
_name | Name of uniform in shader |
_value | value of the type |
Definition at line 418 of file RenderObject.cc.
void ACG::RenderObject::setupLineRendering | ( | float | _lineWidth, |
const Vec2f & | _screenSize | ||
) |
Setup rendering of thick lines.
Two default rendering methods for line thickness are available:
Also, this will overwrite the geometry and fragment shader template. Requires support for geometry shaders with glsl 150
Definition at line 449 of file RenderObject.cc.
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 469 of file RenderObject.cc.
QString ACG::RenderObject::toString | ( | ) | const |
Returns a text representation of the RenderObject for debugging purposes.
Definition at line 230 of file RenderObject.cc.
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 301 of file RenderObject.hh.
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 169 of file RenderObject.hh.
GLenum ACG::RenderObject::indexType |
Index element type.
Has to be GL_UNSIGNED_SHORT or GL_UNSIGNED_INT
Definition at line 204 of file RenderObject.hh.
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 290 of file RenderObject.hh.
std::string ACG::RenderObject::name |
Name for logging.
Definition at line 128 of file RenderObject.hh.
GLsizei ACG::RenderObject::numInstances |
\ brief Instancing
Number of instances to render. numinstances <= 0, disables instancing.
Definition at line 211 of file RenderObject.hh.
bool ACG::RenderObject::overlay |
Layer based rendering.
The renderer currently supports two layers:
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.
Definition at line 142 of file RenderObject.hh.
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 189 of file RenderObject.hh.
int ACG::RenderObject::priority |
Priority to allow sorting of objects.
The renderer sorts objects based on priority in ascending order before rendering.
Definition at line 123 of file RenderObject.hh.
ShaderGenDesc ACG::RenderObject::shaderDesc |
Drawmode and other shader params.
Definition at line 232 of file RenderObject.hh.
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)
Definition at line 180 of file RenderObject.hh.
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 165 of file RenderObject.hh.