Developer Documentation
GLSL::Program Class Reference

GLSL program class. More...

#include <OpenFlipper/libs_required/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 211 of file GLSLShader.hh.

Member Function Documentation

◆ bindAttributeLocation()

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 682 of file GLSLShader.cc.

◆ bindFragDataLocation()

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 692 of file GLSLShader.cc.

◆ getAttributeLocation()

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

Get location of the specified attribute.

Parameters
_nameName of the attribute
Returns
Attribute location

Definition at line 702 of file GLSLShader.cc.

◆ getFragDataLocation()

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 724 of file GLSLShader.cc.

◆ getUniformBlockIndex()

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 767 of file GLSLShader.cc.

◆ getUniformBlockOffsets()

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 834 of file GLSLShader.cc.

◆ getUniformBlockSize() [1/2]

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 807 of file GLSLShader.cc.

◆ getUniformBlockSize() [2/2]

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 822 of file GLSLShader.cc.

◆ getUniformLocation()

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

Get location of the specified uniform.

Parameters
_nameName of the uniform
Returns
Attribute uniform

Definition at line 713 of file GLSLShader.cc.

◆ setGeometryInputType()

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 736 of file GLSLShader.cc.

◆ setGeometryOutputType()

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 746 of file GLSLShader.cc.

◆ setGeometryVertexCount()

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 756 of file GLSLShader.cc.

◆ setUniform() [1/21]

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 385 of file GLSLShader.cc.

◆ setUniform() [2/21]

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 398 of file GLSLShader.cc.

◆ setUniform() [3/21]

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 411 of file GLSLShader.cc.

◆ setUniform() [4/21]

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 424 of file GLSLShader.cc.

◆ setUniform() [5/21]

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 437 of file GLSLShader.cc.

◆ setUniform() [6/21]

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 450 of file GLSLShader.cc.

◆ setUniform() [7/21]

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 463 of file GLSLShader.cc.

◆ setUniform() [8/21]

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 476 of file GLSLShader.cc.

◆ setUniform() [9/21]

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 489 of file GLSLShader.cc.

◆ setUniform() [10/21]

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 502 of file GLSLShader.cc.

◆ setUniform() [11/21]

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 515 of file GLSLShader.cc.

◆ setUniform() [12/21]

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 528 of file GLSLShader.cc.

◆ setUniform() [13/21]

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 649 of file GLSLShader.cc.

◆ setUniform() [14/21]

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 542 of file GLSLShader.cc.

◆ setUniform() [15/21]

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 556 of file GLSLShader.cc.

◆ setUniform() [16/21]

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 570 of file GLSLShader.cc.

◆ setUniform() [17/21]

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 584 of file GLSLShader.cc.

◆ setUniform() [18/21]

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 598 of file GLSLShader.cc.

◆ setUniform() [19/21]

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 612 of file GLSLShader.cc.

◆ setUniform() [20/21]

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 624 of file GLSLShader.cc.

◆ setUniform() [21/21]

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 636 of file GLSLShader.cc.

◆ setUniformBlockBinding() [1/2]

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 783 of file GLSLShader.cc.

◆ setUniformBlockBinding() [2/2]

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 796 of file GLSLShader.cc.

◆ setUniformMat3()

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 663 of file GLSLShader.cc.


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