Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes | Friends | List of all members
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:

Public Member Functions

 GLSLProgram ()
 Constructor. More...
 
 ~GLSLProgram ()
 Destructor. Calls deleteProgram(). More...
 
virtual ERenderState type () const
 
virtual ref< RenderStateclone () const
 
bool reload ()
 Reloads all the shaders source and recompiles them and relinks. Returns true on success. More...
 
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. More...
 
void deleteProgram ()
 Deletes the GLSL program calling glDeleteProgram(handle()), see also http://www.opengl.org/sdk/docs/man/xhtml/glDeleteProgram.xml for more information. More...
 
unsigned int handle () const
 The handle of the GLSL program as returned by glCreateProgram() More...
 
void apply (int index, const Camera *, OpenGLContext *ctx) const
 Calls OpenGLContext::useGLSLProgram() More...
 
bool linkProgram (bool force_relink=false)
 Links the GLSLProgram calling glLinkProgram(handle()) only if the program needs to be linked. More...
 
bool linkStatus () const
 
bool linked () const
 Returns true if the program has been succesfully linked. More...
 
void scheduleRelinking ()
 Schedules a relink of the GLSL program. More...
 
bool attachShader (GLSLShader *shader)
 Attaches the GLSLShader to this GLSLProgram. More...
 
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. More...
 
void discardAllShaders ()
 Detaches all the shaders and deletes them (note that the GLSL Program remains still valid). More...
 
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. More...
 
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. More...
 
void bindAttribLocation (unsigned int index, const char *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. More...
 
int getAttribLocation (const char *name) const
 Eqivalento to glGetAttribLocation(handle(), name). More...
 
int shaderCount () const
 Returns the number of GLSLShader objects bound to this GLSLProgram. More...
 
const GLSLShadershader (int i) const
 Returns the i-th GLSLShader objects bound to this GLSLProgram. More...
 
GLSLShadershader (int i)
 Returns the i-th GLSLShader objects bound to this GLSLProgram. More...
 
void detachAllShaders ()
 Removes all the previously linked shaders and schedules a relinking. More...
 
void bindFragDataLocation (int color_number, const char *name)
 
void unbindFragDataLocation (const char *name)
 
int fragDataLocation (const char *name) const
 
const std::map< std::string, int > & fragDataLocations () const
 
void setProgramBinaryRetrievableHint (bool hint)
 Indicate to the implementation the intention of the application to retrieve the program's binary representation with glGetProgramBinary. More...
 
bool programBinaryRetrievableHint () const
 Indicate to the implementation the intention of the application to retrieve the program's binary representation with glGetProgramBinary. More...
 
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. More...
 
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. More...
 
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 More...
 
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 More...
 
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 More...
 
bool applyUniformSet (const UniformSet *uniforms=NULL) const
 Applies a set of uniforms to the currently bound GLSL program. More...
 
int getUniformLocation (const char *name) const
 Returns the binding index of the given uniform. More...
 
void getUniformfv (int location, float *params) const
 Equivalent to glGetUniformfv(handle(), location, params) More...
 
void getUniformfv (const char *name, float *params) const
 Equivalent to getUniformfv(getUniformLocation(name), params) More...
 
void getUniformiv (int location, int *params) const
 Equivalent to glGetUniformiv(handle(), location, params) More...
 
void getUniformiv (const char *name, int *params) const
 Equivalent to getUniformiv(getUniformLocation(name) More...
 
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 char *name, fvec2 &vec) const
 
void getUniform (const char *name, fvec3 &vec) const
 
void getUniform (const char *name, fvec4 &vec) const
 
void getUniform (const char *name, fmat2 &mat) const
 
void getUniform (const char *name, fmat3 &mat) const
 
void getUniform (const char *name, fmat4 &mat) const
 
void getUniform (const char *name, ivec2 &vec) const
 
void getUniform (const char *name, ivec3 &vec) const
 
void getUniform (const char *name, ivec4 &vec) const
 
UniformSetgetUniformSet ()
 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. More...
 
const UniformSetgetUniformSet () 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. More...
 
void setUniformSet (UniformSet *uniforms)
 Sets a GLSLProgram's static UniformSet. More...
 
void setUniform (Uniform *uniform)
 Utility function using getUniformSet(). Adds a Uniform to this program's static uniform set. More...
 
UniformgetUniform (const char *name)
 Utility function using getUniformSet(). Returns the specified Uniform. Returns NULL if there isn't such a Uniform. More...
 
UniformgocUniform (const char *name)
 Utility function using getUniformSet(). Gets or creates the specified Uniform. More...
 
void eraseUniform (const char *name)
 Utility function using getUniformSet(). Erases the specified uniform. More...
 
void eraseUniform (const Uniform *uniform)
 Utility function using getUniformSet(). Erases the specified uniform. More...
 
void eraseAllUniforms ()
 Utility function using getUniformSet(). Erases all the uniforms. More...
 
int vl_WorldMatrix () const
 Returns the binding location of the vl_WorldMatrix uniform variable or -1 if no such variable is used by the GLSLProgram. More...
 
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. More...
 
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. More...
 
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. More...
 
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 vl_NormalMatrix is simply transpose( inverse( vl_ModelViewMatrix ) ) which usually allows to transform normals without having to renormalized them one by one by undoing the scaling that might be present in vl_ModelViewMatrix. More...
 
int vl_VertexPosition () const
 
int vl_VertexNormal () const
 
int vl_VertexColor () const
 
int vl_VertexSecondaryColor () const
 
int vl_VertexFogCoord () const
 
int vl_VertexTexCoord0 () const
 
int vl_VertexTexCoord1 () const
 
int vl_VertexTexCoord2 () const
 
int vl_VertexTexCoord3 () const
 
int vl_VertexTexCoord4 () const
 
int vl_VertexTexCoord5 () const
 
int vl_VertexTexCoord6 () const
 
int vl_VertexTexCoord7 () const
 
int vl_VertexTexCoord8 () const
 
int vl_VertexTexCoord9 () const
 
int vl_VertexTexCoord10 () const
 
- Public Member Functions inherited from vl::RenderStateNonIndexed
 RenderStateNonIndexed ()
 
- Public Member Functions inherited from vl::RenderState
 RenderState ()
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Protected Attributes

std::vector< ref< GLSLShader > > mShaders
 
std::map< std::string, int > mFragDataLocation
 
ref< UniformSetmUniformSet
 
unsigned int mHandle
 
bool mScheduleLink
 
bool mProgramBinaryRetrievableHint
 
bool mProgramSeparable
 
int m_vl_WorldMatrix
 
int m_vl_ModelViewMatrix
 
int m_vl_ProjectionMatrix
 
int m_vl_ModelViewProjectionMatrix
 
int m_vl_NormalMatrix
 
int m_vl_VertexPosition
 
int m_vl_VertexNormal
 
int m_vl_VertexColor
 
int m_vl_VertexSecondaryColor
 
int m_vl_VertexFogCoord
 
int m_vl_VertexTexCoord0
 
int m_vl_VertexTexCoord1
 
int m_vl_VertexTexCoord2
 
int m_vl_VertexTexCoord3
 
int m_vl_VertexTexCoord4
 
int m_vl_VertexTexCoord5
 
int m_vl_VertexTexCoord6
 
int m_vl_VertexTexCoord7
 
int m_vl_VertexTexCoord8
 
int m_vl_VertexTexCoord9
 
int m_vl_VertexTexCoord10
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Friends

class Renderer
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

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 OpenGLContext::useGLSLProgram() to activate the GLSLProgram and directly call glUniform* (see also getUniformLocation()).
  2. add a Uniform to the GLSLProgram UniformSet, see vl::GLSLProgram::getUniformSet().
  3. add a Uniform to the Actor's UniformSet, see vl::Actor::getUniformSet().
  4. add a Uniform to the Actor's Shader UniformSet, see vl::Shader::getUniformSet().
  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.

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 233 of file GLSL.hpp.

Constructor & Destructor Documentation

◆ GLSLProgram()

GLSLProgram::GLSLProgram ( )

Constructor.

Definition at line 280 of file GLSL.cpp.

References vl::GLSLShader::mHandle.

◆ ~GLSLProgram()

GLSLProgram::~GLSLProgram ( )

Destructor. Calls deleteProgram().

Definition at line 291 of file GLSL.cpp.

References vl::GLSLShader::handle().

Member Function Documentation

◆ apply()

void GLSLProgram::apply ( int  index,
const Camera ,
OpenGLContext ctx 
) const
virtual

◆ applyUniformSet()

bool GLSLProgram::applyUniformSet ( const UniformSet uniforms = NULL) const

◆ attachShader()

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 354 of file GLSL.cpp.

References vl::GLSLShader::compile(), vl::GLSLShader::createShader(), vl::GLSLShader::handle(), vl::Has_GLSL, VL_CHECK, and VL_CHECK_OGL.

Referenced by vlX::VLXClassWrapper_GLSLProgram::importGLSLProgram(), and vl::Terrain::init().

◆ bindAttribLocation()

void GLSLProgram::bindAttribLocation ( unsigned int  index,
const char *  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.

Definition at line 633 of file GLSL.cpp.

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

◆ bindFragDataLocation()

void GLSLProgram::bindFragDataLocation ( int  color_number,
const char *  name 
)

Definition at line 775 of file GLSL.cpp.

Referenced by vlX::VLXClassWrapper_GLSLProgram::importGLSLProgram().

◆ clone()

virtual ref<RenderState> vl::GLSLProgram::clone ( ) const
inlinevirtual

Implements vl::RenderState.

Definition at line 249 of file GLSL.hpp.

◆ createProgram()

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 324 of file GLSL.cpp.

References vl::GLSLShader::handle(), vl::Has_GLSL, vl::GLSLShader::mHandle, VL_CHECK, and VL_CHECK_OGL.

◆ deleteProgram()

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 339 of file GLSL.cpp.

References vl::GLSLShader::handle(), vl::Has_GLSL, vl::GLSLShader::mHandle, and VL_CHECK.

◆ detachAllShaders()

void GLSLProgram::detachAllShaders ( )

Removes all the previously linked shaders and schedules a relinking.

Definition at line 386 of file GLSL.cpp.

References VL_CHECK_OGL.

◆ detachShader()

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 394 of file GLSL.cpp.

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

◆ discardAllShaders()

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 420 of file GLSL.cpp.

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

◆ eraseAllUniforms()

void vl::GLSLProgram::eraseAllUniforms ( )
inline

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

Definition at line 486 of file GLSL.hpp.

◆ eraseUniform() [1/2]

void vl::GLSLProgram::eraseUniform ( const char *  name)
inline

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

Definition at line 482 of file GLSL.hpp.

◆ eraseUniform() [2/2]

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

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

Definition at line 484 of file GLSL.hpp.

◆ fragDataLocation()

int GLSLProgram::fragDataLocation ( const char *  name) const

Definition at line 787 of file GLSL.cpp.

◆ fragDataLocations()

const std::map<std::string, int>& vl::GLSLProgram::fragDataLocations ( ) const
inline

Definition at line 353 of file GLSL.hpp.

Referenced by vlX::VLXClassWrapper_GLSLProgram::exportGLSLProgram().

◆ getAttribLocation()

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 320 of file GLSL.hpp.

References vl::Has_GLSL, VL_CHECK, and VL_CHECK_OGL.

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

◆ getProgramBinary()

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 796 of file GLSL.cpp.

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

◆ getUniform() [1/19]

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

Definition at line 450 of file GLSL.hpp.

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

◆ getUniform() [2/19]

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

Definition at line 451 of file GLSL.hpp.

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

◆ getUniform() [3/19]

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

Definition at line 452 of file GLSL.hpp.

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

◆ getUniform() [4/19]

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

Definition at line 453 of file GLSL.hpp.

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

◆ getUniform() [5/19]

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

Definition at line 454 of file GLSL.hpp.

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

◆ getUniform() [6/19]

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

Definition at line 455 of file GLSL.hpp.

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

◆ getUniform() [7/19]

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

Definition at line 456 of file GLSL.hpp.

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

◆ getUniform() [8/19]

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

Definition at line 457 of file GLSL.hpp.

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

◆ getUniform() [9/19]

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

Definition at line 458 of file GLSL.hpp.

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

◆ getUniform() [10/19]

void vl::GLSLProgram::getUniform ( const char *  name,
fvec2 vec 
) const
inline

Definition at line 459 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [11/19]

void vl::GLSLProgram::getUniform ( const char *  name,
fvec3 vec 
) const
inline

Definition at line 460 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [12/19]

void vl::GLSLProgram::getUniform ( const char *  name,
fvec4 vec 
) const
inline

Definition at line 461 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [13/19]

void vl::GLSLProgram::getUniform ( const char *  name,
fmat2 mat 
) const
inline

Definition at line 462 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [14/19]

void vl::GLSLProgram::getUniform ( const char *  name,
fmat3 mat 
) const
inline

Definition at line 463 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [15/19]

void vl::GLSLProgram::getUniform ( const char *  name,
fmat4 mat 
) const
inline

Definition at line 464 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [16/19]

void vl::GLSLProgram::getUniform ( const char *  name,
ivec2 vec 
) const
inline

Definition at line 465 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [17/19]

void vl::GLSLProgram::getUniform ( const char *  name,
ivec3 vec 
) const
inline

Definition at line 466 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [18/19]

void vl::GLSLProgram::getUniform ( const char *  name,
ivec4 vec 
) const
inline

Definition at line 467 of file GLSL.hpp.

References getUniform().

Referenced by getUniform().

◆ getUniform() [19/19]

Uniform* vl::GLSLProgram::getUniform ( const char *  name)
inline

Utility function using getUniformSet(). Returns the specified Uniform. Returns NULL if there isn't such a Uniform.

Definition at line 478 of file GLSL.hpp.

References NULL.

◆ getUniformfv() [1/2]

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

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

Definition at line 424 of file GLSL.hpp.

References vl::Has_GLSL, VL_CHECK, and VL_CHECK_OGL.

◆ getUniformfv() [2/2]

void vl::GLSLProgram::getUniformfv ( const char *  name,
float *  params 
) const
inline

Equivalent to getUniformfv(getUniformLocation(name), params)

Definition at line 434 of file GLSL.hpp.

References getUniformfv().

Referenced by getUniformfv().

◆ getUniformiv() [1/2]

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

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

Definition at line 436 of file GLSL.hpp.

References vl::Has_GLSL, VL_CHECK, and VL_CHECK_OGL.

◆ getUniformiv() [2/2]

void vl::GLSLProgram::getUniformiv ( const char *  name,
int *  params 
) const
inline

Equivalent to getUniformiv(getUniformLocation(name)

Definition at line 446 of file GLSL.hpp.

References getUniformiv().

Referenced by getUniformiv().

◆ getUniformLocation()

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

Returns the binding index of the given uniform.

Definition at line 405 of file GLSL.hpp.

References vl::Has_GLSL, VL_CHECK, and VL_CHECK_OGL.

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

◆ getUniformSet() [1/2]

UniformSet* vl::GLSLProgram::getUniformSet ( )
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 470 of file GLSL.hpp.

Referenced by vlX::VLXClassWrapper_GLSLProgram::exportGLSLProgram(), and vl::Renderer::renderRaw().

◆ getUniformSet() [2/2]

const UniformSet* vl::GLSLProgram::getUniformSet ( ) 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 472 of file GLSL.hpp.

◆ gocUniform()

Uniform* vl::GLSLProgram::gocUniform ( const char *  name)
inline

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

Definition at line 480 of file GLSL.hpp.

◆ handle()

unsigned int vl::GLSLProgram::handle ( ) const
inline

The handle of the GLSL program as returned by glCreateProgram()

See also
http://www.opengl.org/sdk/docs/man/xhtml/glCreateProgram.xml

Definition at line 273 of file GLSL.hpp.

Referenced by vl::Renderer::renderRaw(), and vl::OpenGLContext::useGLSLProgram().

◆ infoLog()

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 593 of file GLSL.cpp.

References vl::GLSLShader::handle(), vl::Has_GLSL, NULL, vl::Object::objectName(), VL_CHECK, and VL_CHECK_OGL.

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

◆ linked()

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

Returns true if the program has been succesfully linked.

Definition at line 288 of file GLSL.hpp.

Referenced by vl::Rendering::fillRenderQueue(), vl::Renderer::renderRaw(), and vl::OpenGLContext::useGLSLProgram().

◆ linkProgram()

bool GLSLProgram::linkProgram ( bool  force_relink = false)

◆ linkStatus()

bool GLSLProgram::linkStatus ( ) const

Definition at line 576 of file GLSL.cpp.

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

◆ programBinary() [1/2]

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 387 of file GLSL.hpp.

References vl::length(), NULL, and programBinary().

Referenced by programBinary().

◆ programBinary() [2/2]

bool GLSLProgram::programBinary ( GLenum  binary_format,
const void *  binary,
int  length 
)

◆ programBinaryRetrievableHint()

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 367 of file GLSL.hpp.

◆ programSeparable()

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 381 of file GLSL.hpp.

◆ reload()

bool GLSLProgram::reload ( )

Reloads all the shaders source and recompiles them and relinks. Returns true on success.

Definition at line 874 of file GLSL.cpp.

◆ scheduleRelinking()

void vl::GLSLProgram::scheduleRelinking ( )
inline

Schedules a relink of the GLSL program.

Definition at line 291 of file GLSL.hpp.

◆ setProgramBinaryRetrievableHint()

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 362 of file GLSL.hpp.

◆ setProgramSeparable()

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 371 of file GLSL.hpp.

◆ setUniform()

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

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

Definition at line 476 of file GLSL.hpp.

Referenced by vlX::VLXClassWrapper_GLSLProgram::importGLSLProgram(), and vl::Terrain::init().

◆ setUniformSet()

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

Sets a GLSLProgram's static UniformSet.

Definition at line 474 of file GLSL.hpp.

◆ shader() [1/2]

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

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

Definition at line 337 of file GLSL.hpp.

Referenced by vlX::VLXClassWrapper_GLSLProgram::exportGLSLProgram().

◆ shader() [2/2]

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

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

Definition at line 340 of file GLSL.hpp.

◆ shaderCount()

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

Returns the number of GLSLShader objects bound to this GLSLProgram.

Definition at line 334 of file GLSL.hpp.

Referenced by vlX::VLXClassWrapper_GLSLProgram::exportGLSLProgram(), and vl::OpenGLContext::useGLSLProgram().

◆ type()

virtual ERenderState vl::GLSLProgram::type ( ) const
inlinevirtual

Reimplemented from vl::RenderState.

Definition at line 247 of file GLSL.hpp.

References vl::RS_GLSLProgram.

◆ unbindFragDataLocation()

void GLSLProgram::unbindFragDataLocation ( const char *  name)

Definition at line 781 of file GLSL.cpp.

◆ validateProgram()

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 615 of file GLSL.cpp.

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

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

◆ vl_ModelViewMatrix()

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.

vl_ModelViewMatrix transforms a point from object space to camera space.

Definition at line 494 of file GLSL.hpp.

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

◆ vl_ModelViewProjectionMatrix()

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 502 of file GLSL.hpp.

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

◆ vl_NormalMatrix()

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 vl_NormalMatrix is simply transpose( inverse( vl_ModelViewMatrix ) ) which usually allows to transform normals without having to renormalized them one by one by undoing the scaling that might be present in vl_ModelViewMatrix.

Definition at line 507 of file GLSL.hpp.

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

◆ vl_ProjectionMatrix()

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.

vl_ProjectionMatrix is used to transform a point from camera space to projection space (ie. clip coordinates; you can get normalized device coordinates by dividing x, y & z by w). See http://www.songho.ca/opengl/gl_projectionmatrix.html.

Definition at line 499 of file GLSL.hpp.

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

◆ vl_VertexColor()

int vl::GLSLProgram::vl_VertexColor ( ) const
inline

Definition at line 513 of file GLSL.hpp.

◆ vl_VertexFogCoord()

int vl::GLSLProgram::vl_VertexFogCoord ( ) const
inline

Definition at line 515 of file GLSL.hpp.

◆ vl_VertexNormal()

int vl::GLSLProgram::vl_VertexNormal ( ) const
inline

Definition at line 512 of file GLSL.hpp.

◆ vl_VertexPosition()

int vl::GLSLProgram::vl_VertexPosition ( ) const
inline

Definition at line 511 of file GLSL.hpp.

◆ vl_VertexSecondaryColor()

int vl::GLSLProgram::vl_VertexSecondaryColor ( ) const
inline

Definition at line 514 of file GLSL.hpp.

◆ vl_VertexTexCoord0()

int vl::GLSLProgram::vl_VertexTexCoord0 ( ) const
inline

Definition at line 516 of file GLSL.hpp.

◆ vl_VertexTexCoord1()

int vl::GLSLProgram::vl_VertexTexCoord1 ( ) const
inline

Definition at line 517 of file GLSL.hpp.

◆ vl_VertexTexCoord10()

int vl::GLSLProgram::vl_VertexTexCoord10 ( ) const
inline

Definition at line 526 of file GLSL.hpp.

◆ vl_VertexTexCoord2()

int vl::GLSLProgram::vl_VertexTexCoord2 ( ) const
inline

Definition at line 518 of file GLSL.hpp.

◆ vl_VertexTexCoord3()

int vl::GLSLProgram::vl_VertexTexCoord3 ( ) const
inline

Definition at line 519 of file GLSL.hpp.

◆ vl_VertexTexCoord4()

int vl::GLSLProgram::vl_VertexTexCoord4 ( ) const
inline

Definition at line 520 of file GLSL.hpp.

◆ vl_VertexTexCoord5()

int vl::GLSLProgram::vl_VertexTexCoord5 ( ) const
inline

Definition at line 521 of file GLSL.hpp.

◆ vl_VertexTexCoord6()

int vl::GLSLProgram::vl_VertexTexCoord6 ( ) const
inline

Definition at line 522 of file GLSL.hpp.

◆ vl_VertexTexCoord7()

int vl::GLSLProgram::vl_VertexTexCoord7 ( ) const
inline

Definition at line 523 of file GLSL.hpp.

◆ vl_VertexTexCoord8()

int vl::GLSLProgram::vl_VertexTexCoord8 ( ) const
inline

Definition at line 524 of file GLSL.hpp.

◆ vl_VertexTexCoord9()

int vl::GLSLProgram::vl_VertexTexCoord9 ( ) const
inline

Definition at line 525 of file GLSL.hpp.

◆ vl_WorldMatrix()

int vl::GLSLProgram::vl_WorldMatrix ( ) const
inline

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

vl_WorldMatrix transforms a point from object space to world space.

Definition at line 490 of file GLSL.hpp.

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

Friends And Related Function Documentation

◆ Renderer

friend class Renderer
friend

Definition at line 238 of file GLSL.hpp.

Member Data Documentation

◆ m_vl_ModelViewMatrix

int vl::GLSLProgram::m_vl_ModelViewMatrix
protected

Definition at line 548 of file GLSL.hpp.

◆ m_vl_ModelViewProjectionMatrix

int vl::GLSLProgram::m_vl_ModelViewProjectionMatrix
protected

Definition at line 550 of file GLSL.hpp.

◆ m_vl_NormalMatrix

int vl::GLSLProgram::m_vl_NormalMatrix
protected

Definition at line 551 of file GLSL.hpp.

◆ m_vl_ProjectionMatrix

int vl::GLSLProgram::m_vl_ProjectionMatrix
protected

Definition at line 549 of file GLSL.hpp.

◆ m_vl_VertexColor

int vl::GLSLProgram::m_vl_VertexColor
protected

Definition at line 557 of file GLSL.hpp.

◆ m_vl_VertexFogCoord

int vl::GLSLProgram::m_vl_VertexFogCoord
protected

Definition at line 559 of file GLSL.hpp.

◆ m_vl_VertexNormal

int vl::GLSLProgram::m_vl_VertexNormal
protected

Definition at line 556 of file GLSL.hpp.

◆ m_vl_VertexPosition

int vl::GLSLProgram::m_vl_VertexPosition
protected

Definition at line 555 of file GLSL.hpp.

◆ m_vl_VertexSecondaryColor

int vl::GLSLProgram::m_vl_VertexSecondaryColor
protected

Definition at line 558 of file GLSL.hpp.

◆ m_vl_VertexTexCoord0

int vl::GLSLProgram::m_vl_VertexTexCoord0
protected

Definition at line 560 of file GLSL.hpp.

◆ m_vl_VertexTexCoord1

int vl::GLSLProgram::m_vl_VertexTexCoord1
protected

Definition at line 561 of file GLSL.hpp.

◆ m_vl_VertexTexCoord10

int vl::GLSLProgram::m_vl_VertexTexCoord10
protected

Definition at line 570 of file GLSL.hpp.

◆ m_vl_VertexTexCoord2

int vl::GLSLProgram::m_vl_VertexTexCoord2
protected

Definition at line 562 of file GLSL.hpp.

◆ m_vl_VertexTexCoord3

int vl::GLSLProgram::m_vl_VertexTexCoord3
protected

Definition at line 563 of file GLSL.hpp.

◆ m_vl_VertexTexCoord4

int vl::GLSLProgram::m_vl_VertexTexCoord4
protected

Definition at line 564 of file GLSL.hpp.

◆ m_vl_VertexTexCoord5

int vl::GLSLProgram::m_vl_VertexTexCoord5
protected

Definition at line 565 of file GLSL.hpp.

◆ m_vl_VertexTexCoord6

int vl::GLSLProgram::m_vl_VertexTexCoord6
protected

Definition at line 566 of file GLSL.hpp.

◆ m_vl_VertexTexCoord7

int vl::GLSLProgram::m_vl_VertexTexCoord7
protected

Definition at line 567 of file GLSL.hpp.

◆ m_vl_VertexTexCoord8

int vl::GLSLProgram::m_vl_VertexTexCoord8
protected

Definition at line 568 of file GLSL.hpp.

◆ m_vl_VertexTexCoord9

int vl::GLSLProgram::m_vl_VertexTexCoord9
protected

Definition at line 569 of file GLSL.hpp.

◆ m_vl_WorldMatrix

int vl::GLSLProgram::m_vl_WorldMatrix
protected

Definition at line 547 of file GLSL.hpp.

◆ mFragDataLocation

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

Definition at line 536 of file GLSL.hpp.

◆ mHandle

unsigned int vl::GLSLProgram::mHandle
protected

Definition at line 538 of file GLSL.hpp.

◆ mProgramBinaryRetrievableHint

bool vl::GLSLProgram::mProgramBinaryRetrievableHint
protected

Definition at line 542 of file GLSL.hpp.

◆ mProgramSeparable

bool vl::GLSLProgram::mProgramSeparable
protected

Definition at line 543 of file GLSL.hpp.

◆ mScheduleLink

bool vl::GLSLProgram::mScheduleLink
protected

Definition at line 539 of file GLSL.hpp.

◆ mShaders

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

Definition at line 535 of file GLSL.hpp.

◆ mUniformSet

ref<UniformSet> vl::GLSLProgram::mUniformSet
protected

Definition at line 537 of file GLSL.hpp.


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