Developer Documentation
GLSL::Program Class Reference

GLSL program class. More...

#include <ACG/ShaderUtils/GLSLShader.hh>

Public Member Functions

 Program ()
 Creates a new GLSL program object.
 
virtual ~Program ()
 Deletes the GLSL program object and frees the linked shader objects.
 
GLuint getProgramId ()
 Returns opengl id.
 
Compilation/Linking
void attach (PtrConstShader _shader)
 Attaches a shader object to the program object.
 
void detach (PtrConstShader _shader)
 Detaches a shader object from the program object.
 
void link ()
 Links the shader objects to the program.
 
Localizations
int getAttributeLocation (const char *_name)
 Get location of the specified attribute. More...
 
int getUniformLocation (const char *_name)
 Get location of the specified uniform. More...
 
int getFragDataLocation (const char *_name)
 Get location of the fragment data output. More...
 
void bindAttributeLocation (unsigned int _index, const char *_name)
 Bind attribute to name. More...
 
void bindFragDataLocation (unsigned int _index, const char *_name)
 Bind fragment output data to name. More...
 
Uniform setters
void setUniform (const char *_name, GLint _value)
 Set int uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec2i &_value)
 Set Vec2i uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec3i &_value)
 Set Vec3i uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec4i &_value)
 Set Vec4i uniform to specified value. More...
 
void setUniform (const char *_name, GLuint _value)
 Set uint uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec2ui &_value)
 Set Vec2ui uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec3ui &_value)
 Set Vec3ui uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec4ui &_value)
 Set Vec4ui uniform to specified value. More...
 
void setUniform (const char *_name, GLfloat _value)
 Set float uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec2f &_value)
 Set Vec2f uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec3f &_value)
 Set Vec3f uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec4f &_value)
 Set Vec4f uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::GLMatrixf &_value, bool _transposed=false)
 Set 4x4fMatrix uniform to specified value. More...
 
void setUniformMat3 (const char *_name, const ACG::GLMatrixf &_value, bool _transposed=false)
 Set 3x3fMatrix uniform to specified value. More...
 
void setUniform (const char *_name, const GLint *_values, int _count)
 Set int array uniform to specified values. More...
 
void setUniform (const char *_name, const GLfloat *_values, int _count)
 Set float array uniform to specified values. More...
 
void setUniform (const char *_name, const ACG::Vec2f *_values, int _count)
 Set Vec2f array uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec3f *_values, int _count)
 Set Vec3f array uniform to specified value. More...
 
void setUniform (const char *_name, const ACG::Vec4f *_values, int _count)
 Set Vec4f array uniform to specified value. More...
 
void setUniform (const char *_name, int _index, bool _value)
 Set an entry of a bool uniform array. More...
 
void setUniform (const char *_name, int _index, int _value)
 Set an entry of a int uniform array. More...
 
void setUniform (const char *_name, int _index, float _value)
 Set an entry of a float uniform array. More...
 
Uniform buffer blocks
GLuint getUniformBlockIndex (const char *_name)
 Get location of the specified uniform buffer. More...
 
void setUniformBlockBinding (GLuint _index, int _binding)
 Set binding point of a uniform buffer. More...
 
void setUniformBlockBinding (const char *_name, int _binding)
 Set binding point of a uniform buffer. More...
 
int getUniformBlockSize (GLuint _index)
 Get size in bytes of a uniform buffer. More...
 
int getUniformBlockSize (const char *_name)
 Get size in bytes of a uniform buffer. More...
 
void getUniformBlockOffsets (int _numUniforms, const char **_names, int *_outOffsets)
 Get offsets of uniforms in a uniform buffer. More...
 
Geometry shader parameters
void setGeometryInputType (GLint _type)
 Set Type of Geometry. More...
 
void setGeometryOutputType (GLint _type)
 Set output type of geometry. More...
 
void setGeometryVertexCount (GLint _numVerticesOut)
 Sets the maximum vertex output of the geometry shader. More...
 
Enable/disable functions
void use ()
 Enables the program object for using.
 
void disable ()
 Resets to standard rendering pipeline.
 
bool isActive ()
 Returns if the program object is currently active.
 
bool isLinked ()
 Returns if the program object has been succesfully linked.
 

Private Attributes

std::list< PtrConstShaderm_linkedShaders
 
GLint m_programId
 
GLint m_linkStatus
 

Detailed Description

GLSL program class.

A GLSL program links together the vertex and fragment shaders.

Definition at line 217 of file GLSLShader.hh.

Member Function Documentation

void GLSL::Program::bindAttributeLocation ( unsigned int  _index,
const char *  _name 
)

Bind attribute to name.

Parameters
_indexIndex of the attribute to be bound
_nameName of the attribute

Definition at line 688 of file GLSLShader.cc.

void GLSL::Program::bindFragDataLocation ( unsigned int  _index,
const char *  _name 
)

Bind fragment output data to name.

Parameters
_indexIndex of the fragment output to be bound
_nameName of the fragment output data

Definition at line 698 of file GLSLShader.cc.

int GLSL::Program::getAttributeLocation ( const char *  _name)

Get location of the specified attribute.

Parameters
_nameName of the attribute
Returns
Attribute location

Definition at line 708 of file GLSLShader.cc.

int GLSL::Program::getFragDataLocation ( const char *  _name)

Get location of the fragment data output.

Parameters
_nameName of the fragment data output
Returns
Fragment data location

Definition at line 730 of file GLSLShader.cc.

GLuint GLSL::Program::getUniformBlockIndex ( const char *  _name)

Get location of the specified uniform buffer.

Program does not have to be active.

Parameters
_namename of the uniform block
Returns
block index

Definition at line 773 of file GLSLShader.cc.

void GLSL::Program::getUniformBlockOffsets ( int  _numUniforms,
const char **  _names,
int *  _outOffsets 
)

Get offsets of uniforms in a uniform buffer.

Program does not have to be active.

Parameters
_numUniformsnumber of uniforms to query offsets for
_namesarray of uniform names in the buffer
_outOffsetsoffset for each uniform

Definition at line 840 of file GLSLShader.cc.

int GLSL::Program::getUniformBlockSize ( GLuint  _index)

Get size in bytes of a uniform buffer.

Program does not have to be active.

Parameters
_indexblock index as returned via getUniformBlockIndex
Returns
block index

Definition at line 813 of file GLSLShader.cc.

int GLSL::Program::getUniformBlockSize ( const char *  _name)

Get size in bytes of a uniform buffer.

Program does not have to be active.

Parameters
_namename of the uniform block
Returns
block index

Definition at line 828 of file GLSLShader.cc.

int GLSL::Program::getUniformLocation ( const char *  _name)

Get location of the specified uniform.

Parameters
_nameName of the uniform
Returns
Attribute uniform

Definition at line 719 of file GLSLShader.cc.

void GLSL::Program::setGeometryInputType ( GLint  _type)

Set Type of Geometry.

valid input types: GL_POINTS, GL_LINES, GL_LINES_ADJACENCY_EXT, GL_TRIANGLES, GL_TRIANGLES_ADJACENCY_EXT

Parameters
_typeGeometry type

Definition at line 742 of file GLSLShader.cc.

void GLSL::Program::setGeometryOutputType ( GLint  _type)

Set output type of geometry.

valid output types: GL_POINTS, GL_LINE_STRIP, GL_TRIANGLE_STRIP

Parameters
_typeOutput geometry type

Definition at line 752 of file GLSLShader.cc.

void GLSL::Program::setGeometryVertexCount ( GLint  _numVerticesOut)

Sets the maximum vertex output of the geometry shader.

Query GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT to get the gpu limitation

Parameters
_numVerticesOutMaximal number of vertices

Definition at line 762 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
GLint  _value 
)

Set int uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 391 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec2i _value 
)

Set Vec2i uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 404 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec3i _value 
)

Set Vec3i uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 417 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec4i _value 
)

Set Vec4i uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 430 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
GLuint  _value 
)

Set uint uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 443 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec2ui _value 
)

Set Vec2ui uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 456 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec3ui _value 
)

Set Vec3ui uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 469 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec4ui _value 
)

Set Vec4ui uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 482 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
GLfloat  _value 
)

Set float uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 495 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec2f _value 
)

Set Vec2f uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 508 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec3f _value 
)

Set Vec3f uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 521 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec4f _value 
)

Set Vec4f uniform to specified value.

Parameters
_nameName of the uniform
_valueNew value of the uniform

Definition at line 534 of file GLSLShader.cc.

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

Set 4x4fMatrix uniform to specified value.

Parameters
_nameName of the uniform
_valueMatrix to be set
_transposedIs the matrix transposed?

Definition at line 655 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const GLint *  _values,
int  _count 
)

Set int array uniform to specified values.

Parameters
_nameName of the uniform to be set
_valuesPointer to an array with the new values
_countNumber of values in the given array

Definition at line 548 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const GLfloat *  _values,
int  _count 
)

Set float array uniform to specified values.

Parameters
_nameName of the uniform to be set
_valuesPointer to an array with the new values
_countNumber of values in the given array

Definition at line 562 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec2f _values,
int  _count 
)

Set Vec2f array uniform to specified value.

Parameters
_nameName of the uniform
_valuesPointer to an array with the new values
_countNumber of values in the given array

Definition at line 576 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec3f _values,
int  _count 
)

Set Vec3f array uniform to specified value.

Parameters
_nameName of the uniform
_valuesPointer to an array with the new values
_countNumber of values in the given array

Definition at line 590 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
const ACG::Vec4f _values,
int  _count 
)

Set Vec4f array uniform to specified value.

Parameters
_nameName of the uniform
_valuesPointer to an array with the new values
_countNumber of values in the given array

Definition at line 604 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
int  _index,
bool  _value 
)

Set an entry of a bool uniform array.

Parameters
_nameName of the uniform to be set
_indexEntry in the array
_valueNew value of the entry

Definition at line 618 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
int  _index,
int  _value 
)

Set an entry of a int uniform array.

Parameters
_nameName of the uniform to be set
_indexEntry in the array
_valueNew value of the entry

Definition at line 630 of file GLSLShader.cc.

void GLSL::Program::setUniform ( const char *  _name,
int  _index,
float  _value 
)

Set an entry of a float uniform array.

Parameters
_nameName of the uniform to be set
_indexEntry in the array
_valueNew value of the entry

Definition at line 642 of file GLSLShader.cc.

void GLSL::Program::setUniformBlockBinding ( GLuint  _index,
int  _binding 
)

Set binding point of a uniform buffer.

Program does not have to be active.

Parameters
_indexblock index as returned via getUniformBlockIndex
_bindingbinding point where the buffer is bound to

Definition at line 789 of file GLSLShader.cc.

void GLSL::Program::setUniformBlockBinding ( const char *  _name,
int  _binding 
)

Set binding point of a uniform buffer.

Program does not have to be active.

Parameters
_namename of the uniform block
_bindingbinding point where the buffer is bound to

Definition at line 802 of file GLSLShader.cc.

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

Set 3x3fMatrix uniform to specified value.

Parameters
_nameName of the uniform
_valueMatrix to be set
_transposedIs the matrix transposed?

Definition at line 669 of file GLSLShader.cc.


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