Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends

vl::GLSLProgram Class Reference

Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders. More...

#include <GLSL.hpp>

Inheritance diagram for vl::GLSLProgram:
vl::RenderState vl::Object

List of all members.

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)
 Detaches a GLSLShader from the GLSLShader (note: it does NOT schedule a relink of the program), see also http://www.opengl.org/sdk/docs/man/xhtml/glDetachShader.xml for more information.
void discardAllShaders ()
 Detaches all the shaders and deletes them (note that the GLSL Program remains still valid).
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 addAutoAttribLocation (const char *attr_name, int attr_index)
 Adds an attribute name / index pair to the automatic attribute location binding list.
void removeAutoAttribLocation (const char *attr_name)
 Removes an attribute from the automatic attribute location binding list.
void setAutoAttribLocations (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 > & 
autoAttribLocations () const
 Returns which attribute name should be automatically bound to which attribute index at GLSL program linking time.
void clearAutoAttribLocations ()
 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 GLSLShadershader (int i) const
 Returns the i-th GLSLShader objects bound to this GLSLProgram.
GLSLShadershader (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 setProgramBinaryRetrievableHint (bool hint)
 Indicate to the implementation the intention of the application to retrieve the program's binary representation with glGetProgramBinary.
bool programBinaryRetrievableHint () const
 Indicate to the implementation the intention of the application to retrieve the program's binary representation with glGetProgramBinary.
void setProgramSeparable (bool separable)
 Indicates whether program can be bound to individual pipeline stages via glUseProgramStages, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramParameter.xml.
bool programSeparable () const
 Indicates whether program can be bound to individual pipeline stages via glUseProgramStages, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramParameter.xml.
bool getProgramBinary (GLenum &binary_format, std::vector< unsigned char > &binary) const
 glGetProgramBinary wrapper: returns a binary representation of a program object's compiled and linked executable source, see also http://www.opengl.org/sdk/docs/man4/xhtml/glGetProgramBinary.xml
bool programBinary (GLenum binary_format, const std::vector< unsigned char > &binary)
 glProgramBinary wrapper: loads a program object with a program binary, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramBinary.xml
bool programBinary (GLenum binary_format, const void *binary, int length)
 glProgramBinary wrapper: loads a program object with a program binary, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramBinary.xml
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 given uniform.
int getUniformLocation (const char *name) const
 Returns the binding index of the given uniform.
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
UniformSetuniformSet ()
 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 UniformSetuniformSet () 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.
UniformgetUniform (const std::string &name)
 Utility function using uniformSet(). Returns the specified Uniform. Returns NULL if there isn't such a Uniform.
UniformgocUniform (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.
const std::map< std::string,
int > & 
activeUniformLocations () const
 Returns a map of the currently active uniforms and their relative location index.
int vl_ModelViewMatrix () const
 Returns the binding location of the vl_ModelViewMatrix uniform variable or -1 if no such variable is used by the GLSLProgram.
int vl_ProjectionMatrix () const
 Returns the binding location of the vl_ProjectionMatrix uniform variable or -1 if no such variable is used by the GLSLProgram.
int vl_ModelViewProjectionMatrix () const
 Returns the binding location of the vl_ModelViewProjectionMatrix uniform variable or -1 if no such variable is used by the GLSLProgram.
int vl_NormalMatrix () const
 Returns the binding location of the vl_NormalMatrix uniform variable or -1 if no such variable is used by the GLSLProgram.

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 > mActiveUniformLocation
std::map< std::string, int > mAutoAttribLocation
ref< UniformSetmUniformSet
unsigned int mHandle
bool mScheduleLink
int mGeometryVerticesOut
EGeometryInputType mGeometryInputType
EGeometryOutputType mGeometryOutputType
bool mProgramBinaryRetrievableHint
bool mProgramSeparable
int m_vl_ModelViewMatrix
int m_vl_ProjectionMatrix
int m_vl_ModelViewProjectionMatrix
int m_vl_NormalMatrix

Friends

class Renderer

Detailed Description

Wraps a GLSL program to which you can bind vertex, fragment and geometry shaders.

Uniforms
You have 5 ways to set the value of a uniform:
  1. call useProgram() to activate the GLSLProgram and directly call glUniform* (see also getUniformLocation()).
  2. add a Uniform to the GLSLProgram UniformSet, see vl::GLSLProgram::uniformSet().
  3. add a Uniform to the Actor's UniformSet, see vl::Actor::uniformSet().
  4. add a Uniform to the Actor's Shader UniformSet, see vl::Shader::uniformSet().
  5. directly update the uniform value from ActorEventCallback::onActorRenderStarted() using the standard glUniform*() OpenGL functions. In this case you have to make sure that all the Actors using a given GLSLProgram/Shader write such uniform.
Remarks:
A Uniform must be setup using one and only one of the 5 previously mentioned methods.
Attribute Location Bindings
In order to explicity specify which attribute index should be bound to which attribute name you can do one of the following.
  1. call glBindAttribLocation() with the appropriate GLSLProgram::handle(). This is the most low level way of doing it.
  2. call bindAttribLocation() as you would do normally with glBindAttribLocation() but with the difference the you don't need to specify the GLSL program handle.
  3. create a list of attribute name/indices that will be automatically bound whenever the GLSLProgram is linked. In order to do so you can use the following functions setAutoAttribLocations(), autoAttribLocations(), clearAutoAttribLocations(), addAutoAttribLocation(), removeAutoAttribLocation().

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

See also:

Definition at line 215 of file GLSL.hpp.


Constructor & Destructor Documentation

GLSLProgram::GLSLProgram (  )
GLSLProgram::~GLSLProgram (  )

Destructor. Calls deleteProgram().

Definition at line 228 of file GLSL.cpp.

References deleteProgram(), and handle().


Member Function Documentation

virtual const char* vl::GLSLProgram::className (  ) [inline, virtual]

Returns the name of the class.

Reimplemented from vl::RenderState.

Definition at line 226 of file GLSL.hpp.

virtual ERenderState vl::GLSLProgram::type (  ) const [inline, virtual]

Reimplemented from vl::RenderState.

Definition at line 229 of file GLSL.hpp.

References vl::RS_GLSLProgram.

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.

Note:
The program is created only if handle() == 0

Definition at line 234 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, handle(), mHandle, scheduleRelinking(), VL_CHECK, and VL_CHECK_OGL.

Referenced by attachShader(), bindAttribLocation(), linkProgram(), and programBinary().

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.

Definition at line 249 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, handle(), mHandle, scheduleRelinking(), and VL_CHECK.

Referenced by ~GLSLProgram().

unsigned int vl::GLSLProgram::handle (  ) const [inline]
bool GLSLProgram::useProgram (  ) const

Equivalent to glUseProgram(handle()), see also http://www.opengl.org/sdk/docs/man/xhtml/glUseProgram.xml for more information.

Definition at line 570 of file GLSL.cpp.

References vl::Log::bug(), GLEW_Has_Shading_Language_20, handle(), linked(), vl::Object::objectName(), VL_CHECK, VL_CHECK_OGL, and VL_TRAP.

Referenced by apply().

void GLSLProgram::apply ( const Camera ,
OpenGLContext ctx 
) const [virtual]

Calls useProgram()

Implements vl::RenderState.

Definition at line 608 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, handle(), useProgram(), and VL_CHECK_OGL.

bool GLSLProgram::linkProgram ( bool  force_relink = false )
bool GLSLProgram::linkStatus (  ) const

Definition at line 493 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, handle(), VL_CHECK, and VL_CHECK_OGL.

Referenced by linkProgram(), and programBinary().

bool vl::GLSLProgram::linked (  ) const [inline]

Returns true if the program has been succesfully linked.

Definition at line 263 of file GLSL.hpp.

Referenced by applyUniformSet(), vl::Rendering::fillRenderQueue(), linkProgram(), programBinary(), vl::Renderer::render(), and useProgram().

void vl::GLSLProgram::scheduleRelinking (  ) [inline]

Schedules a relink of the GLSL program.

Definition at line 266 of file GLSL.hpp.

Referenced by attachShader(), bindAttribLocation(), bindFragDataLocation(), createProgram(), deleteProgram(), and unbindFragDataLocation().

bool GLSLProgram::attachShader ( GLSLShader shader )

Attaches the GLSLShader to this GLSLProgram.

Note:
Attaching a shader triggers the compilation of the shader (if not already compiled) and relinking of the program.

Definition at line 263 of file GLSL.cpp.

References vl::GLSLShader::compile(), createProgram(), detachShader(), GLEW_Has_Shading_Language_20, handle(), vl::GLSLShader::handle(), mShaders, scheduleRelinking(), shader(), VL_CHECK, and VL_CHECK_OGL.

bool GLSLProgram::detachShader ( GLSLShader shader )

Detaches a GLSLShader from the GLSLShader (note: it does NOT schedule a relink of the program), see also http://www.opengl.org/sdk/docs/man/xhtml/glDetachShader.xml for more information.

Definition at line 305 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, vl::GLSLShader::handle(), handle(), mShaders, VL_CHECK, and VL_CHECK_OGL.

Referenced by attachShader(), and detachAllShaders().

void GLSLProgram::discardAllShaders (  )

Detaches all the shaders and deletes them (note that the GLSL Program remains still valid).

Use this function when your GLSL program compiled well, you don't want to re-link or re-compile it and you want to save some memory by discarding unnecessary shaders objects.

Definition at line 331 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, handle(), mShaders, VL_CHECK, and VL_CHECK_OGL.

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.

Definition at line 510 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, handle(), vl::Object::objectName(), VL_CHECK, and VL_CHECK_OGL.

Referenced by linkProgram(), and programBinary().

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.

Definition at line 530 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, handle(), VL_CHECK, and VL_CHECK_OGL.

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.

See also:
setAutoAttribLocations(), autoAttribLocations(), clearAutoAttribLocations(), removeAutoAttribLocation(), addAutoAttribLocation()

Definition at line 548 of file GLSL.cpp.

References createProgram(), GLEW_Has_Shading_Language_20, handle(), scheduleRelinking(), VL_CHECK, and VL_CHECK_OGL.

void vl::GLSLProgram::addAutoAttribLocation ( 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.

See also:
setAutoAttribLocations(), autoAttribLocations(), clearAutoAttribLocations(), bindAttribLocation(), removeAutoAttribLocation()

Definition at line 298 of file GLSL.hpp.

void vl::GLSLProgram::removeAutoAttribLocation ( 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.

See also:
setAutoAttribLocations(), autoAttribLocations(), clearAutoAttribLocations(), bindAttribLocation(), addAutoAttribLocation()

Definition at line 303 of file GLSL.hpp.

void vl::GLSLProgram::setAutoAttribLocations ( 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.

See also:
autoAttribLocations(), clearAutoAttribLocations(), bindAttribLocation(), removeAutoAttribLocation(), addAutoAttribLocation()

Definition at line 308 of file GLSL.hpp.

const std::map<std::string, int>& vl::GLSLProgram::autoAttribLocations (  ) const [inline]

Returns which attribute name should be automatically bound to which attribute index at GLSL program linking time.

See also:
setAutoAttribLocations(), clearAutoAttribLocations(), bindAttribLocation(), removeAutoAttribLocation(), addAutoAttribLocation()

Definition at line 313 of file GLSL.hpp.

void vl::GLSLProgram::clearAutoAttribLocations (  ) [inline]

Clears the automatic attribute location binding list.

See also setAutoAttribLocations() and autoAttribLocations().

See also:
setAutoAttribLocations(), autoAttribLocations(), bindAttribLocation(), removeAutoAttribLocation(), addAutoAttribLocation()

Definition at line 318 of file GLSL.hpp.

int vl::GLSLProgram::getAttribLocation ( const char *  name ) const [inline]

Eqivalento to glGetAttribLocation(handle(), name).

Note:
The program must be linked before calling this function.

Definition at line 322 of file GLSL.hpp.

References GLEW_Has_Shading_Language_20, and VL_CHECK.

Referenced by vl::MorphingCallback::onActorRenderStarted().

int GLSLProgram::maxVertexAttribs (  ) [static]

Equivalent to glGetIntegerv( GL_MAX_VERTEX_ATTRIBS, &max )

Definition at line 558 of file GLSL.cpp.

References GLEW_Has_Shading_Language_20, vl::max(), VL_CHECK, and VL_CHECK_OGL.

int vl::GLSLProgram::shaderCount (  ) const [inline]

Returns the number of GLSLShader objects bound to this GLSLProgram.

Definition at line 337 of file GLSL.hpp.

Referenced by linkProgram().

const GLSLShader* vl::GLSLProgram::shader ( int  i ) const [inline]

Returns the i-th GLSLShader objects bound to this GLSLProgram.

Definition at line 339 of file GLSL.hpp.

Referenced by attachShader().

GLSLShader* vl::GLSLProgram::shader ( int  i ) [inline]

Returns the i-th GLSLShader objects bound to this GLSLProgram.

Definition at line 341 of file GLSL.hpp.

void GLSLProgram::detachAllShaders (  )

Removes all the previously linked shaders and schedules a relinking.

Definition at line 297 of file GLSL.cpp.

References detachShader(), mShaders, and VL_CHECK_OGL.

void GLSLProgram::bindFragDataLocation ( int  color_number,
const std::string &  name 
)

Definition at line 730 of file GLSL.cpp.

References mFragDataLocation, and scheduleRelinking().

void GLSLProgram::unbindFragDataLocation ( const std::string &  name )

Definition at line 736 of file GLSL.cpp.

References mFragDataLocation, and scheduleRelinking().

int GLSLProgram::fragDataLocationBinding ( const std::string &  name ) const

Definition at line 742 of file GLSL.cpp.

References mFragDataLocation.

void vl::GLSLProgram::setGeometryVerticesOut ( int  vertex_count ) [inline]

See GL_ARB_geometry_shader4's GL_GEOMETRY_VERTICES_OUT_EXT.

Definition at line 354 of file GLSL.hpp.

int vl::GLSLProgram::geometryVerticesOut (  ) const [inline]

See GL_ARB_geometry_shader4's GL_GEOMETRY_VERTICES_OUT_EXT.

Definition at line 364 of file GLSL.hpp.

void vl::GLSLProgram::setGeometryInputType ( EGeometryInputType  type ) [inline]

See GL_ARB_geometry_shader4's GL_GEOMETRY_INPUT_TYPE_EXT.

Definition at line 367 of file GLSL.hpp.

EGeometryInputType vl::GLSLProgram::geometryInputType (  ) const [inline]

See GL_ARB_geometry_shader4's GL_GEOMETRY_INPUT_TYPE_EXT.

Definition at line 376 of file GLSL.hpp.

void vl::GLSLProgram::setGeometryOutputType ( EGeometryOutputType  type ) [inline]

See GL_ARB_geometry_shader4's GL_GEOMETRY_OUTPUT_TYPE_EXT.

Definition at line 379 of file GLSL.hpp.

EGeometryOutputType vl::GLSLProgram::geometryOutputType (  ) const [inline]

See GL_ARB_geometry_shader4's GL_GEOMETRY_OUTPUT_TYPE_EXT.

Definition at line 389 of file GLSL.hpp.

void vl::GLSLProgram::setProgramBinaryRetrievableHint ( bool  hint ) [inline]

Indicate to the implementation the intention of the application to retrieve the program's binary representation with glGetProgramBinary.

The implementation may use this information to store information that may be useful for a future query of the program's binary. See http://www.opengl.org/sdk/docs/man4/xhtml/glProgramParameter.xml

Definition at line 396 of file GLSL.hpp.

bool vl::GLSLProgram::programBinaryRetrievableHint (  ) const [inline]

Indicate to the implementation the intention of the application to retrieve the program's binary representation with glGetProgramBinary.

The implementation may use this information to store information that may be useful for a future query of the program's binary. See http://www.opengl.org/sdk/docs/man4/xhtml/glProgramParameter.xml

Definition at line 401 of file GLSL.hpp.

void vl::GLSLProgram::setProgramSeparable ( bool  separable ) [inline]

Indicates whether program can be bound to individual pipeline stages via glUseProgramStages, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramParameter.xml.

Note:
Changing the program-separable attribute will schedule a relink of the GLSL program.

Definition at line 405 of file GLSL.hpp.

bool vl::GLSLProgram::programSeparable (  ) const [inline]

Indicates whether program can be bound to individual pipeline stages via glUseProgramStages, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramParameter.xml.

Definition at line 415 of file GLSL.hpp.

bool GLSLProgram::getProgramBinary ( GLenum &  binary_format,
std::vector< unsigned char > &  binary 
) const

glGetProgramBinary wrapper: returns a binary representation of a program object's compiled and linked executable source, see also http://www.opengl.org/sdk/docs/man4/xhtml/glGetProgramBinary.xml

Definition at line 751 of file GLSL.cpp.

References handle(), vl::length(), VL_CHECK, VL_CHECK_OGL, and VL_TRAP.

bool vl::GLSLProgram::programBinary ( GLenum  binary_format,
const std::vector< unsigned char > &  binary 
) [inline]

glProgramBinary wrapper: loads a program object with a program binary, see also http://www.opengl.org/sdk/docs/man4/xhtml/glProgramBinary.xml

Definition at line 421 of file GLSL.hpp.

References programBinary().

Referenced by programBinary().

bool GLSLProgram::programBinary ( GLenum  binary_format,
const void *  binary,
int  length 
)
bool GLSLProgram::applyUniformSet ( const UniformSet uniforms ) const
int vl::GLSLProgram::getUniformLocation ( const std::string &  name ) const [inline]

Returns the binding index of the given uniform.

Definition at line 437 of file GLSL.hpp.

References GLEW_Has_Shading_Language_20, and VL_CHECK.

Referenced by vl::MorphingCallback::onActorRenderStarted(), vl::SlicedVolume::updateUniforms(), and vl::RaycastVolume::updateUniforms().

int vl::GLSLProgram::getUniformLocation ( const char *  name ) const [inline]

Returns the binding index of the given uniform.

Definition at line 451 of file GLSL.hpp.

References GLEW_Has_Shading_Language_20, and VL_CHECK.

void vl::GLSLProgram::getUniformfv ( int  location,
float *  params 
) const [inline]

Equivalent to glGetUniformfv(handle(), location, params)

Definition at line 468 of file GLSL.hpp.

References GLEW_Has_Shading_Language_20, VL_CHECK, and VL_CHECK_OGL.

void vl::GLSLProgram::getUniformfv ( const std::string &  name,
float *  params 
) const [inline]

Equivalent to getUniformfv(getUniformLocation(name), params)

Definition at line 478 of file GLSL.hpp.

References getUniformfv().

Referenced by getUniformfv().

void vl::GLSLProgram::getUniformiv ( int  location,
int *  params 
) const [inline]

Equivalent to glGetUniformiv(handle(), location, params)

Definition at line 480 of file GLSL.hpp.

References GLEW_Has_Shading_Language_20, VL_CHECK, and VL_CHECK_OGL.

void vl::GLSLProgram::getUniformiv ( const std::string &  name,
int *  params 
) const [inline]

Equivalent to getUniformiv(getUniformLocation(name)

Definition at line 490 of file GLSL.hpp.

References getUniformiv().

Referenced by getUniformiv().

void vl::GLSLProgram::getUniform ( int  location,
fvec2 vec 
) const [inline]

Definition at line 494 of file GLSL.hpp.

References vl::Vector2< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( int  location,
fvec3 vec 
) const [inline]

Definition at line 495 of file GLSL.hpp.

References vl::Vector3< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( int  location,
fvec4 vec 
) const [inline]

Definition at line 496 of file GLSL.hpp.

References vl::Vector4< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( int  location,
fmat2 mat 
) const [inline]

Definition at line 497 of file GLSL.hpp.

References vl::Matrix2< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( int  location,
fmat3 mat 
) const [inline]

Definition at line 498 of file GLSL.hpp.

References vl::Matrix3< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( int  location,
fmat4 mat 
) const [inline]

Definition at line 499 of file GLSL.hpp.

References vl::Matrix4< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( int  location,
ivec2 vec 
) const [inline]

Definition at line 500 of file GLSL.hpp.

References vl::Vector2< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( int  location,
ivec3 vec 
) const [inline]

Definition at line 501 of file GLSL.hpp.

References vl::Vector3< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( int  location,
ivec4 vec 
) const [inline]

Definition at line 502 of file GLSL.hpp.

References vl::Vector4< T_Scalar >::ptr().

void vl::GLSLProgram::getUniform ( const std::string &  name,
fvec2 vec 
) const [inline]

Definition at line 503 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

void vl::GLSLProgram::getUniform ( const std::string &  name,
fvec3 vec 
) const [inline]

Definition at line 504 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

void vl::GLSLProgram::getUniform ( const std::string &  name,
fvec4 vec 
) const [inline]

Definition at line 505 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

void vl::GLSLProgram::getUniform ( const std::string &  name,
fmat2 mat 
) const [inline]

Definition at line 506 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

void vl::GLSLProgram::getUniform ( const std::string &  name,
fmat3 mat 
) const [inline]

Definition at line 507 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

void vl::GLSLProgram::getUniform ( const std::string &  name,
fmat4 mat 
) const [inline]

Definition at line 508 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

void vl::GLSLProgram::getUniform ( const std::string &  name,
ivec2 vec 
) const [inline]

Definition at line 509 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

void vl::GLSLProgram::getUniform ( const std::string &  name,
ivec3 vec 
) const [inline]

Definition at line 510 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

void vl::GLSLProgram::getUniform ( const std::string &  name,
ivec4 vec 
) const [inline]

Definition at line 511 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

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.

Definition at line 516 of file GLSL.hpp.

Referenced by vl::Renderer::render().

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.

Definition at line 518 of file GLSL.hpp.

void vl::GLSLProgram::setUniformSet ( UniformSet uniforms ) [inline]

Sets a GLSLProgram's static UniformSet.

Definition at line 520 of file GLSL.hpp.

void vl::GLSLProgram::setUniform ( Uniform uniform ) [inline]

Utility function using uniformSet(). Adds a Uniform to this program's static uniform set.

Definition at line 522 of file GLSL.hpp.

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.

Definition at line 524 of file GLSL.hpp.

References vl::Uniform::getUniform().

Uniform* vl::GLSLProgram::gocUniform ( const std::string &  name ) [inline]

Utility function using uniformSet(). Gets or creates the specified Uniform.

Definition at line 526 of file GLSL.hpp.

void vl::GLSLProgram::eraseUniform ( const std::string &  name ) [inline]

Utility function using uniformSet(). Erases the specified uniform.

Definition at line 528 of file GLSL.hpp.

void vl::GLSLProgram::eraseUniform ( const Uniform uniform ) [inline]

Utility function using uniformSet(). Erases the specified uniform.

Definition at line 530 of file GLSL.hpp.

void vl::GLSLProgram::eraseAllUniforms (  ) [inline]

Utility function using uniformSet(). Erases all the uniforms.

Definition at line 532 of file GLSL.hpp.

const std::map<std::string, int>& vl::GLSLProgram::activeUniformLocations (  ) const [inline]

Returns a map of the currently active uniforms and their relative location index.

Definition at line 535 of file GLSL.hpp.

int vl::GLSLProgram::vl_ModelViewMatrix (  ) const [inline]

Returns the binding location of the vl_ModelViewMatrix uniform variable or -1 if no such variable is used by the GLSLProgram.

Definition at line 538 of file GLSL.hpp.

Referenced by vl::ProjViewTransfCallback::updateMatrices().

int vl::GLSLProgram::vl_ProjectionMatrix (  ) const [inline]

Returns the binding location of the vl_ProjectionMatrix uniform variable or -1 if no such variable is used by the GLSLProgram.

Definition at line 541 of file GLSL.hpp.

Referenced by vl::ProjViewTransfCallback::updateMatrices().

int vl::GLSLProgram::vl_ModelViewProjectionMatrix (  ) const [inline]

Returns the binding location of the vl_ModelViewProjectionMatrix uniform variable or -1 if no such variable is used by the GLSLProgram.

Definition at line 544 of file GLSL.hpp.

Referenced by vl::ProjViewTransfCallback::updateMatrices().

int vl::GLSLProgram::vl_NormalMatrix (  ) const [inline]

Returns the binding location of the vl_NormalMatrix uniform variable or -1 if no such variable is used by the GLSLProgram.

Definition at line 547 of file GLSL.hpp.

Referenced by vl::ProjViewTransfCallback::updateMatrices().


Friends And Related Function Documentation

friend class Renderer [friend]

Definition at line 218 of file GLSL.hpp.


Member Data Documentation

std::vector< ref<GLSLShader> > vl::GLSLProgram::mShaders [protected]

Definition at line 554 of file GLSL.hpp.

Referenced by attachShader(), detachAllShaders(), detachShader(), and discardAllShaders().

std::map<std::string, int> vl::GLSLProgram::mFragDataLocation [protected]

Definition at line 555 of file GLSL.hpp.

Referenced by bindFragDataLocation(), fragDataLocationBinding(), and unbindFragDataLocation().

std::map<std::string, int> vl::GLSLProgram::mActiveUniformLocation [protected]

Definition at line 556 of file GLSL.hpp.

Referenced by applyUniformSet().

std::map<std::string, int> vl::GLSLProgram::mAutoAttribLocation [protected]

Definition at line 557 of file GLSL.hpp.

Definition at line 558 of file GLSL.hpp.

unsigned int vl::GLSLProgram::mHandle [protected]

Definition at line 559 of file GLSL.hpp.

Referenced by createProgram(), deleteProgram(), and GLSLProgram().

Definition at line 560 of file GLSL.hpp.

Referenced by GLSLProgram(), linkProgram(), and programBinary().

Definition at line 562 of file GLSL.hpp.

Referenced by GLSLProgram().

Definition at line 563 of file GLSL.hpp.

Referenced by GLSLProgram().

Definition at line 564 of file GLSL.hpp.

Referenced by GLSLProgram().

Definition at line 565 of file GLSL.hpp.

Referenced by GLSLProgram().

Definition at line 566 of file GLSL.hpp.

Referenced by GLSLProgram().

Definition at line 567 of file GLSL.hpp.

Referenced by GLSLProgram().

Definition at line 568 of file GLSL.hpp.

Referenced by GLSLProgram().

Definition at line 569 of file GLSL.hpp.

Referenced by GLSLProgram().

Definition at line 570 of file GLSL.hpp.

Referenced by GLSLProgram().


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

Visualization Library v2011.05.1144 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Tue Sep 13 2011 21:59:14.
Permission is granted to use this page to write and publish articles regarding Visualization Library.