Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
#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 *) const |
| Calls useProgram(). | |
| virtual void | initResources () |
| Calls linkProgram() and applyes this program's uniforms. | |
| 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()). | |
| 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. | |
| void | 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. | |
| const UniformSet * | uniformSet () const |
| Returns a GLSLProgram's 'static' UniformSet. | |
| void | setUniformSet (UniformSet *uniforms) |
| Sets a GLSLProgram's 'static' UniformSet. | |
| void | setUniform (Uniform *uniform) |
| Sets a GLSLProgram's 'static' Uniform. | |
| Uniform * | getUniform (const std::string &name) |
| Returns the specified Uniform. Returns NULL if there isn't such a Uniform. | |
| Uniform * | gocUniform (const std::string &name) |
| Gets or creates the specified Uniform. | |
Static Public Member Functions | |
| static int | maxVertexAttributes () |
| 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 |
| ref< UniformSet > | mUniformSet |
| unsigned int | mHandle |
| bool | mScheduleLink |
| int | mGeometryVerticesOut |
| EGeometryInputType | mGeometryInputType |
| EGeometryOutputType | mGeometryOutputType |
Friends | |
| class | Renderer |
| GLSLProgram::GLSLProgram | ( | ) |
Constructor.
| GLSLProgram::~GLSLProgram | ( | ) |
Destructor. Calls deleteProgram().
| virtual const char* vl::GLSLProgram::className | ( | ) | [inline, virtual] |
| 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 * | ) | const [virtual] |
| void GLSLProgram::initResources | ( | ) | [virtual] |
Calls linkProgram() and applyes this program's uniforms.
Reimplemented from 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 GLSLProgram::scheduleRelinking | ( | ) |
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()).
| int vl::GLSLProgram::getAttribLocation | ( | const char * | name | ) | const [inline] |
Eqivalento to glGetAttribLocation(handle(), name).
| int GLSLProgram::maxVertexAttributes | ( | ) | [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.
| void 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.
| const UniformSet* vl::GLSLProgram::uniformSet | ( | ) | const [inline] |
Returns a GLSLProgram's 'static' UniformSet.
| void vl::GLSLProgram::setUniformSet | ( | UniformSet * | uniforms | ) | [inline] |
Sets a GLSLProgram's 'static' UniformSet.
| void vl::GLSLProgram::setUniform | ( | Uniform * | uniform | ) | [inline] |
Sets a GLSLProgram's 'static' Uniform.
This is an utility function, it is equivalent to:
if (!uniformSet()) setUniformSet(new UniformSet); uniformSet()->setUniform(uniform);
| Uniform* vl::GLSLProgram::getUniform | ( | const std::string & | name | ) | [inline] |
| Uniform* vl::GLSLProgram::gocUniform | ( | const std::string & | name | ) | [inline] |
Gets or creates the specified Uniform.
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] |
ref<UniformSet> vl::GLSLProgram::mUniformSet [protected] |
unsigned int vl::GLSLProgram::mHandle [protected] |
bool vl::GLSLProgram::mScheduleLink [protected] |
int vl::GLSLProgram::mGeometryVerticesOut [protected] |