GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
Glip::CoreGL::HdlProgram Class Reference

Object handle for OpenGL Program (A vertex and a fragment program). More...

#include <HdlShader.hpp>

Public Member Functions

 HdlProgram (void)
 HdlProgram constructor.
 
bool isValid (void) const
 Check if the program is valid. More...
 
void updateShader (const HdlShader &shader, bool linkNow=true)
 Change a shader in the program. More...
 
void link (void)
 Link the program. More...
 
void use (void)
 Start using the program with OpenGL.
 
const std::vector< std::string > & getUniformsNames (void) const
 Get access to the list of uniform variables names of supported types managed by the program (GL based). More...
 
const std::vector< GLenum > & getUniformsTypes (void) const
 Get access to the list of uniform variables types corresponding to the names provided by HdlProgram::getUniformsNames (GL based). More...
 
void setFragmentLocation (const std::string &fragName, int frag)
 Link the name of a fragment output variable to a fragment unit. More...
 
void setVar (const std::string &varName, GLenum type, int v0, int v1=0, int v2=0, int v3=0)
 Change a uniform variable in a shader. Raise an exception if any error occur. More...
 
void setVar (const std::string &varName, GLenum type, int *v)
 Change a uniform variable in a shader. Raise an exception if any error occur. More...
 
void setVar (const std::string &varName, GLenum type, unsigned int v0, unsigned int v1=0, unsigned int v2=0, unsigned int v3=0)
 Change a uniform variable in a shader. Raise an exception if any error occur. More...
 
void setVar (const std::string &varName, GLenum type, unsigned int *v)
 Change a uniform variable in a shader. Raise an exception if any error occur. More...
 
void setVar (const std::string &varName, GLenum type, float v0, float v1=0, float v2=0, float v3=0)
 Change a uniform variable in a shader. Raise an exception if any error occur. More...
 
void setVar (const std::string &varName, GLenum type, float *v)
 Change a uniform variable in a shader. Raise an exception if any error occur. More...
 
void setVar (const std::string &varName, const HdlDynamicData &data)
 Change a uniform variable in a shader. Raise an exception if any error occur. More...
 
void getVar (const std::string &varName, int *ptr)
 Read a uniform variable from a shader. Warning : this function does not perform any type or size check which might result in a buffer overflow if not used with care. More...
 
void getVar (const std::string &varName, unsigned int *ptr)
 Read a uniform variable from a shader. Warning : this function does not perform any type or size check which might result in a buffer overflow if not used with care. More...
 
void getVar (const std::string &varName, float *ptr)
 Read a uniform variable from a shader. Warning : this function does not perform any type or size check which might result in a buffer overflow if not used with care. More...
 
void getVar (const std::string &varName, HdlDynamicData &data)
 Read a uniform variable from a shader. Warning : this function does not perform any type or size check which might result in a buffer overflow if not used with care. More...
 
bool isUniformVariableValid (const std::string &varName)
 Check if a variable is valid from its name. More...
 

Static Public Member Functions

static int maxVaryingVar (void)
 Returns the maximum number of varying variables available. More...
 
static void stopProgram (void)
 Stop using a program.
 

Detailed Description

Object handle for OpenGL Program (A vertex and a fragment program).

Member Function Documentation

const std::vector< std::string > & HdlProgram::getUniformsNames ( void  ) const

Get access to the list of uniform variables names of supported types managed by the program (GL based).

Some variable reported by the Driver might not be accessible. You can use HdlProgram::isUniformVariableValid to detect such variables.

Returns
Access to a string based vector.
const std::vector< GLenum > & HdlProgram::getUniformsTypes ( void  ) const

Get access to the list of uniform variables types corresponding to the names provided by HdlProgram::getUniformsNames (GL based).

Some variable reported by the Driver might not be accessible. You can use HdlProgram::isUniformVariableValid to detect such variables.

Returns
Access to a GLenum based vector, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types.
void HdlProgram::getVar ( const std::string &  varName,
int *  ptr 
)

Read a uniform variable from a shader. Warning : this function does not perform any type or size check which might result in a buffer overflow if not used with care.

Parameters
varNameThe name of the uniform variable to read from.
ptrA pointer to a buffer with sufficient size in order to contain the full object (scalar, vector, matrix...).
void HdlProgram::getVar ( const std::string &  varName,
unsigned int *  ptr 
)

Read a uniform variable from a shader. Warning : this function does not perform any type or size check which might result in a buffer overflow if not used with care.

Parameters
varNameThe name of the uniform variable to read from.
ptrA pointer to a buffer with sufficient size in order to contain the full object (scalar, vector, matrix...).
void HdlProgram::getVar ( const std::string &  varName,
float *  ptr 
)

Read a uniform variable from a shader. Warning : this function does not perform any type or size check which might result in a buffer overflow if not used with care.

Parameters
varNameThe name of the uniform variable to read from.
ptrA pointer to a buffer with sufficient size in order to contain the full object (scalar, vector, matrix...).
void HdlProgram::getVar ( const std::string &  varName,
HdlDynamicData data 
)

Read a uniform variable from a shader. Warning : this function does not perform any type or size check which might result in a buffer overflow if not used with care.

Parameters
varNameName of the fragment output variable.
dataThe dynamic object to be used as target.
bool HdlProgram::isUniformVariableValid ( const std::string &  varName)

Check if a variable is valid from its name.

Parameters
varNameThe name of the uniform variable to read from.
Returns
True if the name is valid (see glGetUniformLocation at http://www.opengl.org/sdk/docs/man/xhtml/glGetUniformLocation.xml) or false otherwise.
bool HdlProgram::isValid ( void  ) const

Check if the program is valid.

Returns
True if the Program is valid, false otherwise.
void HdlProgram::link ( void  )

Link the program.

Returns
False in case of failure, true otherwise.

WARNING : This step might remove all the uniform values previously set.

int HdlProgram::maxVaryingVar ( void  )
static

Returns the maximum number of varying variables available.

Returns
The maximum number of varying variables.
void HdlProgram::setFragmentLocation ( const std::string &  fragName,
int  frag 
)

Link the name of a fragment output variable to a fragment unit.

Parameters
fragNameName of the fragment output variable.
fragIndex of the desired fragment unit.

Note that the program should be linked after this call in order to push the changes.

void HdlProgram::setVar ( const std::string &  varName,
GLenum  type,
int  v0,
int  v1 = 0,
int  v2 = 0,
int  v3 = 0 
)

Change a uniform variable in a shader. Raise an exception if any error occur.

Parameters
varNameName of the fragment output variable.
typeKind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types.
v0Corresponding value to assign.
v1Corresponding value to assign.
v2Corresponding value to assign.
v3Corresponding value to assign.
void HdlProgram::setVar ( const std::string &  varName,
GLenum  t,
int *  v 
)

Change a uniform variable in a shader. Raise an exception if any error occur.

Parameters
varNameName of the fragment output variable.
tKind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types.
vPointer to the values to assign.
void HdlProgram::setVar ( const std::string &  varName,
GLenum  type,
unsigned int  v0,
unsigned int  v1 = 0,
unsigned int  v2 = 0,
unsigned int  v3 = 0 
)

Change a uniform variable in a shader. Raise an exception if any error occur.

Parameters
varNameName of the fragment output variable.
typeKind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types.
v0Corresponding value to assign.
v1Corresponding value to assign.
v2Corresponding value to assign.
v3Corresponding value to assign.
void HdlProgram::setVar ( const std::string &  varName,
GLenum  t,
unsigned int *  v 
)

Change a uniform variable in a shader. Raise an exception if any error occur.

Parameters
varNameName of the fragment output variable.
tKind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types.
vPointer to the values to assign.
void HdlProgram::setVar ( const std::string &  varName,
GLenum  type,
float  v0,
float  v1 = 0,
float  v2 = 0,
float  v3 = 0 
)

Change a uniform variable in a shader. Raise an exception if any error occur.

Parameters
varNameName of the fragment output variable.
typeKind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types.
v0Corresponding value to assign.
v1Corresponding value to assign.
v2Corresponding value to assign.
v3Corresponding value to assign.
void HdlProgram::setVar ( const std::string &  varName,
GLenum  t,
float *  v 
)

Change a uniform variable in a shader. Raise an exception if any error occur.

Parameters
varNameName of the fragment output variable.
tKind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types.
vPointer to the values to assign.
void HdlProgram::setVar ( const std::string &  varName,
const HdlDynamicData data 
)

Change a uniform variable in a shader. Raise an exception if any error occur.

Parameters
varNameName of the fragment output variable.
dataThe dynamic object to be used as source.
void HdlProgram::updateShader ( const HdlShader shader,
bool  linkNow = true 
)

Change a shader in the program.

Parameters
shaderThe shader to add.
linkNowLink the program now.

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