46#include <ACG/GL/gl.hh>
47#include <ACG/Math/GLMatrixT.hh>
48#include <ACG/GL/ShaderGenerator.hh>
49#include <ACG/ShaderUtils/UniformPool.hh>
62class VertexDeclaration;
67 class DrawModeProperties;
237 GLboolean colorWriteMask[4];
255 GLuint clipDistanceMask;
260 bool programPointSize;
269 Vec2f patchDefaultInnerLevel;
270 Vec4f patchDefaultOuterLevel;
318 Texture(GLuint _id = 0, GLenum _type = GL_TEXTURE_2D,
bool _shadow =
false):
328 addTexture(_t,numTextures());
336 if (GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS < numTextures())
338 std::cerr <<
"Texturestage " << _stage <<
" is too big. Allowed stages: "<< GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS << std::endl;
341 textures_[_stage] = _t;
349 const std::map<size_t,Texture>& textures(){
return textures_;}
351 size_t numTextures() {
return textures_.size();}
361 std::string debugName;
370 inline void glBindBuffer(GLenum target, GLuint buffer)
374 case GL_ARRAY_BUFFER: vertexBuffer = buffer;
break;
375 case GL_ELEMENT_ARRAY_BUFFER: indexBuffer = buffer;
break;
379 inline void glDrawArrays(GLenum mode, GLint first, GLsizei count)
381 this->glDrawInstancedArrays(mode, first, count, 0);
384 inline void glDrawInstancedArrays(GLenum mode, GLint first, GLsizei count, GLsizei primcount)
387 sysmemIndexBuffer = 0;
389 primitiveMode = mode;
392 numInstances = primcount;
395 inline void glDrawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices)
397 this->glDrawElementsInstanced(mode, count, type, indices, 0);
400 inline void glDrawElementsInstanced(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount)
402 primitiveMode = mode;
406 sysmemIndexBuffer = indices;
408 numInstances = primcount;
411 inline void glColorMask(GLboolean r, GLboolean g, GLboolean b, GLboolean a)
413 colorWriteMask[0] = r; colorWriteMask[1] = g; colorWriteMask[2] = b; colorWriteMask[3] = a;
416 inline void glAlphaFunc(GLenum func,
float ref)
426 void initFromState(GLState* _glState);
428 void setMaterial(
const SceneGraph::Material* _mat);
432 void setupShaderGenFromDrawmode(
const SceneGraph::DrawModes::DrawModeProperties* _props);
445 void setupLineRendering(
float _lineWidth,
const Vec2f& _screenSize);
448 bool isDefaultLineObject()
const;
451 void resetLineRendering();
459 void setupPointRendering(
float _pointSize,
const Vec2f& _screenSize);
462 bool isDefaultPointObject()
const;
465 void resetPointRendering();
471 QString toString()
const;
479 void setUniform(
const char *_name, GLint _value);
487 void setUniform(
const char *_name, GLfloat _value);
495 void setUniform(
const char *_name,
const ACG::Vec2f &_value);
503 void setUniform(
const char *_name,
const ACG::Vec3f &_value);
511 void setUniform(
const char *_name,
const ACG::Vec4f &_value);
513 void setUniform(
const char *_name,
const ACG::GLMatrixf &_value,
bool _transposed =
false);
514 void setUniformMat3(
const char *_name,
const ACG::GLMatrixf &_value,
bool _transposed =
false);
517 void setUniform(
const char *_name, GLint *_values,
int _count);
518 void setUniform(
const char *_name, GLfloat *_values,
int _count);
554 const std::string&
name()
const {
return name_; }
Interface for modifying render objects.
virtual void apply(RenderObject *_obj)=0
apply the modifier
const std::string & name() const
Get name of the modifier.
void addTextureType(GLenum _type, bool _shadow, size_t _stage)
adds a texture type to the shader and enables texturing.
void clearTextures()
disables texture support and removes all texture types
Class to define the vertex input layout.
Namespace providing different geometric functions concerning angles.
This namespace contains all the classes and functions for handling GLSL shader and program objects.
Interface class between scenegraph and renderer.
int debugID
used internally for renderer debugging
const char * depthMapUniformName
Uniform name of the depth map in the used shader.
Vec3f diffuse
material definitions
ShaderGenDesc shaderDesc
Drawmode and other shader params.
GLuint vertexArrayObject
Use vertex array object.
const VertexDeclaration * vertexDecl
Defines the vertex buffer layout, ignored if VAO is provided.
const void * sysmemIndexBuffer
Use system memory index buffer.
void addTexture(const Texture &_t)
adds a texture to stage RenderObjects::numTextures()
GLuint indexBuffer
Use vertex array object.
int priority
Priority to allow sorting of objects.
unsigned int numIndices
Number indices to render.
GLMatrixd modelview
Modelview transform.
GLMatrixd proj
Projection transform.
std::map< size_t, Texture > textures_
holds the textures (second) and the stage id (first)
std::string name
Name for logging.
bool inZPrePass
Specify whether this object should be rendered in a z-prepass.
bool overlay
Layer based rendering.
void addTexture(const Texture &_t, const size_t _stage, bool _addToShaderGen=true)
unsigned int indexOffset
Offset to first index in the index buffer or vertex buffer respectively.
GLuint vertexBuffer
VBO, IBO ids, ignored if VAO is provided.
GLenum primitiveMode
Primitive type.
GLenum alphaFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
unsigned int patchVertices
patch size if primitiveMode is GL_PATCHES for rendering with tessellation shaders
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
Vec2f depthRange
glDepthRange: (znear, zmax)
GLenum indexType
Index element type.
GLenum depthFunc
GL_LESS, GL_LEQUAL, GL_GREATER ..
void clearTextures()
clear all textures. Also affected on shaderDesc