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. | |
Object handle for OpenGL Program (A vertex and a fragment program).
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.
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.
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.
varName | The name of the uniform variable to read from. |
ptr | A 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.
varName | The name of the uniform variable to read from. |
ptr | A 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.
varName | The name of the uniform variable to read from. |
ptr | A 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.
varName | Name of the fragment output variable. |
data | The dynamic object to be used as target. |
bool HdlProgram::isUniformVariableValid | ( | const std::string & | varName | ) |
Check if a variable is valid from its name.
varName | The name of the uniform variable to read from. |
bool HdlProgram::isValid | ( | void | ) | const |
Check if the program is valid.
void HdlProgram::link | ( | void | ) |
Link the program.
WARNING : This step might remove all the uniform values previously set.
|
static |
Returns the maximum number of varying variables available.
void HdlProgram::setFragmentLocation | ( | const std::string & | fragName, |
int | frag | ||
) |
Link the name of a fragment output variable to a fragment unit.
fragName | Name of the fragment output variable. |
frag | Index 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.
varName | Name of the fragment output variable. |
type | Kind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types. |
v0 | Corresponding value to assign. |
v1 | Corresponding value to assign. |
v2 | Corresponding value to assign. |
v3 | Corresponding 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.
varName | Name of the fragment output variable. |
t | Kind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types. |
v | Pointer 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.
varName | Name of the fragment output variable. |
type | Kind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types. |
v0 | Corresponding value to assign. |
v1 | Corresponding value to assign. |
v2 | Corresponding value to assign. |
v3 | Corresponding 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.
varName | Name of the fragment output variable. |
t | Kind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types. |
v | Pointer 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.
varName | Name of the fragment output variable. |
type | Kind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types. |
v0 | Corresponding value to assign. |
v1 | Corresponding value to assign. |
v2 | Corresponding value to assign. |
v3 | Corresponding 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.
varName | Name of the fragment output variable. |
t | Kind of variable in, see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for possible types. |
v | Pointer 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.
varName | Name of the fragment output variable. |
data | The dynamic object to be used as source. |
void HdlProgram::updateShader | ( | const HdlShader & | shader, |
bool | linkNow = true |
||
) |
Change a shader in the program.
shader | The shader to add. |
linkNow | Link the program now. |