53 #include <ACG/GL/gl.hh>
54 #include <ACG/Math/GLMatrixT.hh>
55 #include <ACG/GL/ShaderGenerator.hh>
56 #include <ACG/ShaderUtils/UniformPool.hh>
69 class VertexDeclaration;
72 namespace SceneGraph {
74 class DrawModeProperties;
244 GLboolean colorWriteMask[4];
262 Vec2f patchDefaultInnerLevel;
263 Vec4f patchDefaultOuterLevel;
311 Texture(GLuint _id = 0, GLenum _type = GL_TEXTURE_2D,
bool _shadow =
false):
321 addTexture(_t,numTextures());
329 if (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS < numTextures())
331 std::cerr <<
"Texturestage " << _stage <<
" is too big. Allowed stages: "<< GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS << std::endl;
334 textures_[_stage] = _t;
342 const std::map<size_t,Texture>& textures(){
return textures_;}
344 size_t numTextures() {
return textures_.size();}
354 const char* debugName;
363 inline void glBindBuffer(GLenum target, GLuint buffer)
367 case GL_ARRAY_BUFFER: vertexBuffer = buffer;
break;
368 case GL_ELEMENT_ARRAY_BUFFER: indexBuffer = buffer;
break;
372 inline void glDrawArrays(GLenum mode, GLint first, GLsizei count)
374 this->glDrawInstancedArrays(mode, first, count, 0);
377 inline void glDrawInstancedArrays(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
380 sysmemIndexBuffer = 0;
382 primitiveMode = mode;
385 numInstances = primcount;
388 inline void glDrawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices)
390 this->glDrawElementsInstanced(mode, count, type, indices, 0);
393 inline void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount)
395 primitiveMode = mode;
399 sysmemIndexBuffer = indices;
401 numInstances = primcount;
404 inline void glColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a)
406 colorWriteMask[0] = r; colorWriteMask[1] = g; colorWriteMask[2] = b; colorWriteMask[3] = a;
409 inline void glAlphaFunc(GLenum func,
float ref)
419 void initFromState(GLState* _glState);
421 void setMaterial(
const SceneGraph::Material* _mat);
425 void setupShaderGenFromDrawmode(
const SceneGraph::DrawModes::DrawModeProperties* _props);
438 void setupLineRendering(
float _lineWidth,
const Vec2f& _screenSize);
441 bool isDefaultLineObject()
const;
444 void resetLineRendering();
452 void setupPointRendering(
float _pointSize,
const Vec2f& _screenSize);
455 bool isDefaultPointObject()
const;
458 void resetPointRendering();
464 QString toString()
const;
472 void setUniform(
const char *_name, GLint _value);
480 void setUniform(
const char *_name, GLfloat _value);
488 void setUniform(
const char *_name,
const ACG::Vec2f &_value);
496 void setUniform(
const char *_name,
const ACG::Vec3f &_value);
504 void setUniform(
const char *_name,
const ACG::Vec4f &_value);
506 void setUniform(
const char *_name,
const ACG::GLMatrixf &_value,
bool _transposed =
false);
507 void setUniformMat3(
const char *_name,
const ACG::GLMatrixf &_value,
bool _transposed =
false);
510 void setUniform(
const char *_name, GLint *_values,
int _count);
511 void setUniform(
const char *_name, GLfloat *_values,
int _count);
544 virtual void apply(RenderObject* _obj) = 0;
ShaderGenDesc shaderDesc
Drawmode and other shader params.
Vec2f depthRange
glDepthRange: (znear, zmax)
Namespace providing different geometric functions concerning angles.
std::map< size_t, Texture > textures_
holds the textures (second) and the stage id (first)
GLenum alphaFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
Interface class between scenegraph and renderer.
GLenum blendDest
glBlendFunc: GL_SRC_ALPHA, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ...
void addTextureType(GLenum _type, bool _shadow, size_t _stage)
adds a texture type to the shader and enables texturing.
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
unsigned int internalFlags_
may be used internally by the renderer
GLenum depthFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
void addTexture(const Texture &_t, const size_t _stage, bool _addToShaderGen=true)
GLuint vertexArrayObject
Use vertex array object.
const void * sysmemIndexBuffer
Use system memory index buffer.
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
GLenum primitiveMode
Primitive type.
unsigned int numIndices
Number indices to render.
Vec3f diffuse
material definitions
std::string name
Name for logging.
void clearTextures()
disables texture support and removes all texture types
This namespace contains all the classes and functions for handling GLSL shader and program objects...
void clearTextures()
clear all textures. Also affected on shaderDesc
Class to define the vertex input layout.
void addTexture(const Texture &_t)
adds a texture to stage RenderObjects::numTextures()
GLMatrixd modelview
Modelview transform.
bool overlay
Layer based rendering.
const char * depthMapUniformName
Uniform name of the depth map in the used shader.
GLenum indexType
Index element type.
Interface for modifying render objects.
unsigned int indexOffset
Offset to first index in the index buffer or vertex buffer respectively.
int priority
Priority to allow sorting of objects.
int debugID
used internally for renderer debugging
bool inZPrePass
Specify whether this object should be rendered in a z-prepass.
unsigned int patchVertices
patch size if primitiveMode is GL_PATCHES for rendering with tessellation shaders ...
GLMatrixd proj
Projection transform.