Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. More...
#include <GLSL.hpp>
Public Member Functions | |
| GLSLProgram () | |
| Constructor. | |
| ~GLSLProgram () | |
| Destructor. Calls deleteProgram(). | |
| virtual const char * | className () |
| Returns the name of the class. | |
| virtual ERenderState | type () const |
| void | createProgram () |
| Calls glCreateProgram() in order to acquire a GLSL program handle, see also http://www.opengl.org/sdk/docs/man/xhtml/glCreateProgram.xml for more information. | |
| void | deleteProgram () |
| Deletes the GLSL program calling glDeleteProgram(handle()), see also http://www.opengl.org/sdk/docs/man/xhtml/glDeleteProgram.xml for more information. | |
| unsigned int | handle () const |
| The handle of the GLSL program as returned by glCreateProgram() | |
| bool | useProgram () const |
| Equivalent to glUseProgram(handle()), see also http://www.opengl.org/sdk/docs/man/xhtml/glUseProgram.xml for more information. | |
| void | apply (const Camera *, OpenGLContext *ctx) const |
| Calls useProgram() | |
| bool | linkProgram (bool force_relink=false) |
| Links the GLSLProgram calling glLinkProgram(handle()) only if the program needs to be linked. | |
| bool | linkStatus () const |
| bool | linked () const |
| Returns true if the program has been succesfully linked. | |
| void | scheduleRelinking () |
| Schedules a relink of the GLSL program. | |
| bool | attachShader (GLSLShader *shader) |
| Attaches the GLSLShader to this GLSLProgram. | |
| bool | detachShader (GLSLShader *shader) |
| Removes a GLSLShader from the GLSLShader and schedules a relink of the program, see also http://www.opengl.org/sdk/docs/man/xhtml/glDetachShader.xml for more information. | |
| String | infoLog () const |
| Returns the info log of this GLSL program using the OpenGL function glGetProgramInfoLog(), see also http://www.opengl.org/sdk/docs/man/xhtml/glGetProgramInfoLog.xml for more information. | |
| bool | validateProgram () const |
| Returns true if the validation of this GLSL program is succesful, see also http://www.opengl.org/sdk/docs/man/xhtml/glValidateProgram.xml for more information. | |
| void | bindAttribLocation (unsigned int index, const std::string &name) |
| Equivalent to glBindAttribLocation(handle(), index, name.c_str()) with the difference that this function will automatically create a GLSL program if none is present and it will schedule a re-link since the new specified bindings take effect after linking the GLSL program. | |
| void | addAutomaticAttribLocation (const char *attr_name, int attr_index) |
| Adds an attribute name / index pair to the automatic attribute location binding list. | |
| void | removeAutomaticAttribLocation (const char *attr_name) |
| Removes an attribute from the automatic attribute location binding list. | |
| void | setAutomaticAttribLocations (const std::map< std::string, int > &attrib_bindings) |
Defines which attribute should be automatically bound to which attribute index at GLSL program linking time. | |
| const std::map< std::string, int > & | automaticAttribLocations () const |
Returns which attribute name should be automatically bound to which attribute index at GLSL program linking time. | |
| void | clearAutomaticAttribLocations () |
| Clears the automatic attribute location binding list. | |
| int | getAttribLocation (const char *name) const |
| Eqivalento to glGetAttribLocation(handle(), name). | |
| int | shaderCount () const |
| Returns the number of GLSLShader objects bound to this GLSLProgram. | |
| const GLSLShader * | shader (int i) const |
| Returns the i-th GLSLShader objects bound to this GLSLProgram. | |
| GLSLShader * | shader (int i) |
| Returns the i-th GLSLShader objects bound to this GLSLProgram. | |
| void | detachAllShaders () |
| Removes all the previously linked shaders and schedules a relinking. | |
| void | bindFragDataLocation (int color_number, const std::string &name) |
| void | unbindFragDataLocation (const std::string &name) |
| int | fragDataLocationBinding (const std::string &name) const |
| void | setGeometryVerticesOut (int vertex_count) |
| See GL_ARB_geometry_shader4's GL_GEOMETRY_VERTICES_OUT_EXT. | |
| int | geometryVerticesOut () const |
| See GL_ARB_geometry_shader4's GL_GEOMETRY_VERTICES_OUT_EXT. | |
| void | setGeometryInputType (EGeometryInputType type) |
| See GL_ARB_geometry_shader4's GL_GEOMETRY_INPUT_TYPE_EXT. | |
| EGeometryInputType | geometryInputType () const |
| See GL_ARB_geometry_shader4's GL_GEOMETRY_INPUT_TYPE_EXT. | |
| void | setGeometryOutputType (EGeometryOutputType type) |
| See GL_ARB_geometry_shader4's GL_GEOMETRY_OUTPUT_TYPE_EXT. | |
| EGeometryOutputType | geometryOutputType () const |
| See GL_ARB_geometry_shader4's GL_GEOMETRY_OUTPUT_TYPE_EXT. | |
| bool | applyUniformSet (const UniformSet *uniforms) const |
| Applies a set of uniforms to the currently bound GLSL program. | |
| int | getUniformLocation (const std::string &name) const |
| Returns the binding index of the uniform with the given name. | |
| void | getUniformfv (int location, float *params) const |
| Equivalent to glGetUniformfv(handle(), location, params) | |
| void | getUniformfv (const std::string &name, float *params) const |
| Equivalent to getUniformfv(getUniformLocation(name), params) | |
| void | getUniformiv (int location, int *params) const |
| Equivalent to glGetUniformiv(handle(), location, params) | |
| void | getUniformiv (const std::string &name, int *params) const |
| Equivalent to getUniformiv(getUniformLocation(name) | |
| void | getUniform (int location, fvec2 &vec) const |
| void | getUniform (int location, fvec3 &vec) const |
| void | getUniform (int location, fvec4 &vec) const |
| void | getUniform (int location, fmat2 &mat) const |
| void | getUniform (int location, fmat3 &mat) const |
| void | getUniform (int location, fmat4 &mat) const |
| void | getUniform (int location, ivec2 &vec) const |
| void | getUniform (int location, ivec3 &vec) const |
| void | getUniform (int location, ivec4 &vec) const |
| void | getUniform (const std::string &name, fvec2 &vec) const |
| void | getUniform (const std::string &name, fvec3 &vec) const |
| void | getUniform (const std::string &name, fvec4 &vec) const |
| void | getUniform (const std::string &name, fmat2 &mat) const |
| void | getUniform (const std::string &name, fmat3 &mat) const |
| void | getUniform (const std::string &name, fmat4 &mat) const |
| void | getUniform (const std::string &name, ivec2 &vec) const |
| void | getUniform (const std::string &name, ivec3 &vec) const |
| void | getUniform (const std::string &name, ivec4 &vec) const |
| UniformSet * | uniformSet () |
Returns a GLSLProgram's static UniformSet. Static uniforms are those uniforms whose value is constant across one rendering as opposed to Shader uniforms that change across Shaders and Actor uniforms that change across Actors. | |
| const UniformSet * | uniformSet () const |
Returns a GLSLProgram's static UniformSet. Static uniforms are those uniforms whose value is constant across one rendering as opposed to Shader uniforms that change across Shaders and Actor uniforms that change across Actors. | |
| void | setUniformSet (UniformSet *uniforms) |
Sets a GLSLProgram's static UniformSet. | |
| void | setUniform (Uniform *uniform) |
Utility function using uniformSet(). Adds a Uniform to this program's static uniform set. | |
| Uniform * | getUniform (const std::string &name) |
| Utility function using uniformSet(). Returns the specified Uniform. Returns NULL if there isn't such a Uniform. | |
| Uniform * | gocUniform (const std::string &name) |
| Utility function using uniformSet(). Gets or creates the specified Uniform. | |
| void | eraseUniform (const std::string &name) |
| Utility function using uniformSet(). Erases the specified uniform. | |
| void | eraseUniform (const Uniform *uniform) |
| Utility function using uniformSet(). Erases the specified uniform. | |
| void | eraseAllUniforms () |
| Utility function using uniformSet(). Erases all the uniforms. | |
Static Public Member Functions | |
| static int | maxVertexAttribs () |
| Equivalent to glGetIntegerv( GL_MAX_VERTEX_ATTRIBS, &max ) | |
Protected Attributes | |
| std::vector< ref< GLSLShader > > | mShaders |
| std::map< std::string, int > | mFragDataLocation |
| std::map< std::string, int > | mUniformLocation |
| std::map< std::string, int > | mAttribLocation |
| ref< UniformSet > | mUniformSet |
| unsigned int | mHandle |
| bool | mScheduleLink |
| int | mGeometryVerticesOut |
| EGeometryInputType | mGeometryInputType |
| EGeometryOutputType | mGeometryOutputType |
Friends | |
| class | Renderer |
Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders.
Note that for option #1 and #2 you need to relink the GLSLProgram in order for the changes to take effect (linkProgram(force_relink=true)). Option #2 and #3 automatically schedule a re-link of the GLSL program. See also http://www.opengl.org/sdk/docs/man/xhtml/glBindAttribLocation.xml
| GLSLProgram::GLSLProgram | ( | ) |
Constructor.
| GLSLProgram::~GLSLProgram | ( | ) |
Destructor. Calls deleteProgram().
| virtual const char* vl::GLSLProgram::className | ( | ) | [inline, virtual] |
Returns the name of the class.
Reimplemented from vl::RenderState.
| virtual ERenderState vl::GLSLProgram::type | ( | ) | const [inline, virtual] |
Reimplemented from vl::RenderState.
| void GLSLProgram::createProgram | ( | ) |
Calls glCreateProgram() in order to acquire a GLSL program handle, see also http://www.opengl.org/sdk/docs/man/xhtml/glCreateProgram.xml for more information.
| void GLSLProgram::deleteProgram | ( | ) |
Deletes the GLSL program calling glDeleteProgram(handle()), see also http://www.opengl.org/sdk/docs/man/xhtml/glDeleteProgram.xml for more information.
After this function handle() will return 0.
| unsigned int vl::GLSLProgram::handle | ( | ) | const [inline] |
The handle of the GLSL program as returned by glCreateProgram()
| bool GLSLProgram::useProgram | ( | ) | const |
Equivalent to glUseProgram(handle()), see also http://www.opengl.org/sdk/docs/man/xhtml/glUseProgram.xml for more information.
| void GLSLProgram::apply | ( | const Camera * | , |
| OpenGLContext * | ctx | ||
| ) | const [virtual] |
Calls useProgram()
Implements vl::RenderState.
| bool GLSLProgram::linkProgram | ( | bool | force_relink = false ) |
Links the GLSLProgram calling glLinkProgram(handle()) only if the program needs to be linked.
| bool GLSLProgram::linkStatus | ( | ) | const |
| bool vl::GLSLProgram::linked | ( | ) | const [inline] |
Returns true if the program has been succesfully linked.
| void vl::GLSLProgram::scheduleRelinking | ( | ) | [inline] |
Schedules a relink of the GLSL program.
| bool GLSLProgram::attachShader | ( | GLSLShader * | shader ) |
Attaches the GLSLShader to this GLSLProgram.
| bool GLSLProgram::detachShader | ( | GLSLShader * | shader ) |
Removes a GLSLShader from the GLSLShader and schedules a relink of the program, see also http://www.opengl.org/sdk/docs/man/xhtml/glDetachShader.xml for more information.
| String GLSLProgram::infoLog | ( | ) | const |
Returns the info log of this GLSL program using the OpenGL function glGetProgramInfoLog(), see also http://www.opengl.org/sdk/docs/man/xhtml/glGetProgramInfoLog.xml for more information.
| bool GLSLProgram::validateProgram | ( | ) | const |
Returns true if the validation of this GLSL program is succesful, see also http://www.opengl.org/sdk/docs/man/xhtml/glValidateProgram.xml for more information.
| void GLSLProgram::bindAttribLocation | ( | unsigned int | index, |
| const std::string & | name | ||
| ) |
Equivalent to glBindAttribLocation(handle(), index, name.c_str()) with the difference that this function will automatically create a GLSL program if none is present and it will schedule a re-link since the new specified bindings take effect after linking the GLSL program.
| void vl::GLSLProgram::addAutomaticAttribLocation | ( | const char * | attr_name, |
| int | attr_index | ||
| ) | [inline] |
Adds an attribute name / index pair to the automatic attribute location binding list.
Calling this function will schedule a re-linking of the GLSL program.
| void vl::GLSLProgram::removeAutomaticAttribLocation | ( | const char * | attr_name ) | [inline] |
Removes an attribute from the automatic attribute location binding list.
Calling this function will schedule a re-linking of the GLSL program.
| void vl::GLSLProgram::setAutomaticAttribLocations | ( | const std::map< std::string, int > & | attrib_bindings ) | [inline] |
Defines which attribute should be automatically bound to which attribute index at GLSL program linking time.
Calling this function will schedule a re-linking of the GLSL program.
| const std::map<std::string, int>& vl::GLSLProgram::automaticAttribLocations | ( | ) | const [inline] |
Returns which attribute name should be automatically bound to which attribute index at GLSL program linking time.
| void vl::GLSLProgram::clearAutomaticAttribLocations | ( | ) | [inline] |
Clears the automatic attribute location binding list.
See also setAutomaticAttribLocations() and automaticAttribLocations().
| int vl::GLSLProgram::getAttribLocation | ( | const char * | name ) | const [inline] |
Eqivalento to glGetAttribLocation(handle(), name).
| int GLSLProgram::maxVertexAttribs | ( | ) | [static] |
Equivalent to glGetIntegerv( GL_MAX_VERTEX_ATTRIBS, &max )
| int vl::GLSLProgram::shaderCount | ( | ) | const [inline] |
Returns the number of GLSLShader objects bound to this GLSLProgram.
| const GLSLShader* vl::GLSLProgram::shader | ( | int | i ) | const [inline] |
Returns the i-th GLSLShader objects bound to this GLSLProgram.
| GLSLShader* vl::GLSLProgram::shader | ( | int | i ) | [inline] |
Returns the i-th GLSLShader objects bound to this GLSLProgram.
| void GLSLProgram::detachAllShaders | ( | ) |
Removes all the previously linked shaders and schedules a relinking.
| void GLSLProgram::bindFragDataLocation | ( | int | color_number, |
| const std::string & | name | ||
| ) |
| void GLSLProgram::unbindFragDataLocation | ( | const std::string & | name ) |
| int GLSLProgram::fragDataLocationBinding | ( | const std::string & | name ) | const |
| void vl::GLSLProgram::setGeometryVerticesOut | ( | int | vertex_count ) | [inline] |
See GL_ARB_geometry_shader4's GL_GEOMETRY_VERTICES_OUT_EXT.
| int vl::GLSLProgram::geometryVerticesOut | ( | ) | const [inline] |
See GL_ARB_geometry_shader4's GL_GEOMETRY_VERTICES_OUT_EXT.
| void vl::GLSLProgram::setGeometryInputType | ( | EGeometryInputType | type ) | [inline] |
See GL_ARB_geometry_shader4's GL_GEOMETRY_INPUT_TYPE_EXT.
| EGeometryInputType vl::GLSLProgram::geometryInputType | ( | ) | const [inline] |
See GL_ARB_geometry_shader4's GL_GEOMETRY_INPUT_TYPE_EXT.
| void vl::GLSLProgram::setGeometryOutputType | ( | EGeometryOutputType | type ) | [inline] |
See GL_ARB_geometry_shader4's GL_GEOMETRY_OUTPUT_TYPE_EXT.
| EGeometryOutputType vl::GLSLProgram::geometryOutputType | ( | ) | const [inline] |
See GL_ARB_geometry_shader4's GL_GEOMETRY_OUTPUT_TYPE_EXT.
| bool GLSLProgram::applyUniformSet | ( | const UniformSet * | uniforms ) | const |
Applies a set of uniforms to the currently bound GLSL program.
This function expects the GLSLProgram to be already bound, see useProgram().
| int vl::GLSLProgram::getUniformLocation | ( | const std::string & | name ) | const [inline] |
Returns the binding index of the uniform with the given name.
| void vl::GLSLProgram::getUniformfv | ( | int | location, |
| float * | params | ||
| ) | const [inline] |
Equivalent to glGetUniformfv(handle(), location, params)
| void vl::GLSLProgram::getUniformfv | ( | const std::string & | name, |
| float * | params | ||
| ) | const [inline] |
Equivalent to getUniformfv(getUniformLocation(name), params)
| void vl::GLSLProgram::getUniformiv | ( | int | location, |
| int * | params | ||
| ) | const [inline] |
Equivalent to glGetUniformiv(handle(), location, params)
| void vl::GLSLProgram::getUniformiv | ( | const std::string & | name, |
| int * | params | ||
| ) | const [inline] |
Equivalent to getUniformiv(getUniformLocation(name)
| void vl::GLSLProgram::getUniform | ( | int | location, |
| fvec2 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | int | location, |
| fvec3 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | int | location, |
| fvec4 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | int | location, |
| fmat2 & | mat | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | int | location, |
| fmat3 & | mat | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | int | location, |
| fmat4 & | mat | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | int | location, |
| ivec2 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | int | location, |
| ivec3 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | int | location, |
| ivec4 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| fvec2 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| fvec3 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| fvec4 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| fmat2 & | mat | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| fmat3 & | mat | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| fmat4 & | mat | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| ivec2 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| ivec3 & | vec | ||
| ) | const [inline] |
| void vl::GLSLProgram::getUniform | ( | const std::string & | name, |
| ivec4 & | vec | ||
| ) | const [inline] |
| UniformSet* vl::GLSLProgram::uniformSet | ( | ) | [inline] |
Returns a GLSLProgram's static UniformSet. Static uniforms are those uniforms whose value is constant across one rendering as opposed to Shader uniforms that change across Shaders and Actor uniforms that change across Actors.
| const UniformSet* vl::GLSLProgram::uniformSet | ( | ) | const [inline] |
Returns a GLSLProgram's static UniformSet. Static uniforms are those uniforms whose value is constant across one rendering as opposed to Shader uniforms that change across Shaders and Actor uniforms that change across Actors.
| void vl::GLSLProgram::setUniformSet | ( | UniformSet * | uniforms ) | [inline] |
Sets a GLSLProgram's static UniformSet.
| void vl::GLSLProgram::setUniform | ( | Uniform * | uniform ) | [inline] |
Utility function using uniformSet(). Adds a Uniform to this program's static uniform set.
| Uniform* vl::GLSLProgram::getUniform | ( | const std::string & | name ) | [inline] |
Utility function using uniformSet(). Returns the specified Uniform. Returns NULL if there isn't such a Uniform.
| Uniform* vl::GLSLProgram::gocUniform | ( | const std::string & | name ) | [inline] |
Utility function using uniformSet(). Gets or creates the specified Uniform.
| void vl::GLSLProgram::eraseUniform | ( | const std::string & | name ) | [inline] |
Utility function using uniformSet(). Erases the specified uniform.
| void vl::GLSLProgram::eraseUniform | ( | const Uniform * | uniform ) | [inline] |
Utility function using uniformSet(). Erases the specified uniform.
| void vl::GLSLProgram::eraseAllUniforms | ( | ) | [inline] |
Utility function using uniformSet(). Erases all the uniforms.
friend class Renderer [friend] |
std::vector< ref<GLSLShader> > vl::GLSLProgram::mShaders [protected] |
std::map<std::string, int> vl::GLSLProgram::mFragDataLocation [protected] |
std::map<std::string, int> vl::GLSLProgram::mUniformLocation [protected] |
std::map<std::string, int> vl::GLSLProgram::mAttribLocation [protected] |
ref<UniformSet> vl::GLSLProgram::mUniformSet [protected] |
unsigned int vl::GLSLProgram::mHandle [protected] |
bool vl::GLSLProgram::mScheduleLink [protected] |
int vl::GLSLProgram::mGeometryVerticesOut [protected] |