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;
74 class DrawModeProperties;
244 GLboolean colorWriteMask[4];
262 GLuint clipDistanceMask;
268 Vec2f patchDefaultInnerLevel;
269 Vec4f patchDefaultOuterLevel;
317 Texture(GLuint _id = 0, GLenum _type = GL_TEXTURE_2D,
bool _shadow =
false):
327 addTexture(_t,numTextures());
335 if (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS < numTextures())
337 std::cerr <<
"Texturestage " << _stage <<
" is too big. Allowed stages: "<< GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS << std::endl;
340 textures_[_stage] = _t;
348 const std::map<size_t,Texture>& textures(){
return textures_;}
350 size_t numTextures() {
return textures_.size();}
360 const char* debugName;
369 inline void glBindBuffer(GLenum target, GLuint buffer)
373 case GL_ARRAY_BUFFER: vertexBuffer = buffer;
break;
374 case GL_ELEMENT_ARRAY_BUFFER: indexBuffer = buffer;
break;
378 inline void glDrawArrays(GLenum mode, GLint first, GLsizei count)
380 this->glDrawInstancedArrays(mode, first, count, 0);
383 inline void glDrawInstancedArrays(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
386 sysmemIndexBuffer = 0;
388 primitiveMode = mode;
391 numInstances = primcount;
394 inline void glDrawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices)
396 this->glDrawElementsInstanced(mode, count, type, indices, 0);
399 inline void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount)
401 primitiveMode = mode;
405 sysmemIndexBuffer = indices;
407 numInstances = primcount;
410 inline void glColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a)
412 colorWriteMask[0] = r; colorWriteMask[1] = g; colorWriteMask[2] = b; colorWriteMask[3] = a;
415 inline void glAlphaFunc(GLenum func,
float ref)
425 void initFromState(GLState* _glState);
427 void setMaterial(
const SceneGraph::Material* _mat);
431 void setupShaderGenFromDrawmode(
const SceneGraph::DrawModes::DrawModeProperties* _props);
444 void setupLineRendering(
float _lineWidth,
const Vec2f& _screenSize);
447 bool isDefaultLineObject()
const;
450 void resetLineRendering();
458 void setupPointRendering(
float _pointSize,
const Vec2f& _screenSize);
461 bool isDefaultPointObject()
const;
464 void resetPointRendering();
470 QString toString()
const;
478 void setUniform(
const char *_name, GLint _value);
486 void setUniform(
const char *_name, GLfloat _value);
494 void setUniform(
const char *_name,
const ACG::Vec2f &_value);
502 void setUniform(
const char *_name,
const ACG::Vec3f &_value);
510 void setUniform(
const char *_name,
const ACG::Vec4f &_value);
512 void setUniform(
const char *_name,
const ACG::GLMatrixf &_value,
bool _transposed =
false);
513 void setUniformMat3(
const char *_name,
const ACG::GLMatrixf &_value,
bool _transposed =
false);
516 void setUniform(
const char *_name, GLint *_values,
int _count);
517 void setUniform(
const char *_name, GLfloat *_values,
int _count);
550 virtual void apply(RenderObject* _obj) = 0;
553 const std::string&
name()
const {
return name_; }
GLenum indexType
Index element type.
void addTextureType(GLenum _type, bool _shadow, size_t _stage)
adds a texture type to the shader and enables texturing.
void addTexture(const Texture &_t, const size_t _stage, bool _addToShaderGen=true)
GLenum alphaFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
Namespace providing different geometric functions concerning angles.
GLuint vertexArrayObject
Use vertex array object.
GLenum depthFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
void clearTextures()
clear all textures. Also affected on shaderDesc
unsigned int patchVertices
patch size if primitiveMode is GL_PATCHES for rendering with tessellation shaders ...
bool inZPrePass
Specify whether this object should be rendered in a z-prepass.
const void * sysmemIndexBuffer
Use system memory index buffer.
void clearTextures()
disables texture support and removes all texture types
std::map< size_t, Texture > textures_
holds the textures (second) and the stage id (first)
GLMatrixd proj
Projection transform.
int debugID
used internally for renderer debugging
Vec3f diffuse
material definitions
GLMatrixd modelview
Modelview transform.
Interface for modifying render objects.
Vec2f depthRange
glDepthRange: (znear, zmax)
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
const std::string & name() const
Get name of the modifier.
Class to define the vertex input layout.
std::string name
Name for logging.
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
int priority
Priority to allow sorting of objects.
unsigned int numIndices
Number indices to render.
GLenum blendDest
glBlendFunc: GL_SRC_ALPHA, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA ...
unsigned int internalFlags_
may be used internally by the renderer
This namespace contains all the classes and functions for handling GLSL shader and program objects...
Interface class between scenegraph and renderer.
GLenum primitiveMode
Primitive type.
const char * depthMapUniformName
Uniform name of the depth map in the used shader.
bool overlay
Layer based rendering.
unsigned int indexOffset
Offset to first index in the index buffer or vertex buffer respectively.
void addTexture(const Texture &_t)
adds a texture to stage RenderObjects::numTextures()
ShaderGenDesc shaderDesc
Drawmode and other shader params.