ReTo
0.3.7
|
Class to manage shaders and programs. More...
#include <ShaderProgram.h>
Public Member Functions | |
bool | load (const std::string &vsFile, const std::string &fsFile) |
Method to load and add a vertex and fragment shaders from file. More... | |
bool | loadVertexShader (const std::string &file) |
Method to load and add a vertex shader from file. More... | |
bool | loadFragmentShader (const std::string &file) |
Method to load and add a fragment shader from file. More... | |
bool | loadFromText (const std::string &vsSource, const std::string &fsSource) |
Method to load and add a vertex and fragment shaders from text. More... | |
bool | loadVertexShaderFromText (const std::string &source) |
Method to load and add a vertex shader from text. More... | |
bool | loadFragmentShaderFromText (const std::string &source) |
Method to load and add a fragment shader from text. More... | |
bool | compileAndLink (void) |
Method to compile a program. More... | |
unsigned int | program (void) |
Method to get Program id. More... | |
void | use (void) |
Method to enable a program. | |
void | unuse (void) |
Method to disable a program (not necessary) | |
void | addAttribute (const std::string &attr) |
Method to catching an attribute value of a vertex shader. More... | |
void | addAttributes (const std::vector< char * > attrs) |
Method to catching an array of attribute values of a vertex shader. More... | |
void | bindAttribute (const std::string &attr, unsigned int index) |
Method to bind a specific index to a attribute value. More... | |
void | addUniform (const std::string &unifs) |
Method to catching an uniform value. More... | |
void | addUniforms (const std::vector< char * > uniforms) |
Method to catching an array of uniform values. More... | |
void | bindUniform (const std::string &unif, unsigned int index) |
Method to bind a specific index to a uniform value. More... | |
bool | isUniformCached (const std::string &unif) const |
Method to check if uniform exist (only check in uniform cache) More... | |
bool | isAttributeCached (const std::string &attr) const |
Method to check if attribute exist (only check in attribute cache) More... | |
void | addUbo (const std::string &ubo) |
Method to catching an uniform buffer object. More... | |
int | attribute (const std::string &_attr) |
Method to get a attribute index in cache. More... | |
int | uniform (const std::string &_unif) |
Method to get a uniform index in cache. More... | |
int | ubo (const std::string &ubo) |
Method to get a Uniform Buffer Object index in cache. More... | |
int | subprogram (const std::string &name, int shaderType) |
Method to get a subprogram index of a specific kind of shader in cache. More... | |
int | operator() (const std::string &_attr) |
Method to get a attribute index in cache. More... | |
int | operator[] (const std::string &_unif) |
Method to get a uniform index in cache. More... | |
void | sendUniformb (const std::string &uniform, bool val) |
Method to send a boolean. More... | |
void | sendUniformi (const std::string &uniform, int val) |
Method to send an integer. More... | |
void | sendUniformu (const std::string &uniform, unsigned int val) |
Method to send an unsigned integer. More... | |
void | sendUniformf (const std::string &uniform, float val) |
Method to send a float. More... | |
void | sendUniform (const std::string &uniform, float x, float y, float z) |
Method to send a vec3 with separated data. More... | |
void | sendUniform2v (const std::string &uniform, const std::vector< float > &data) |
Method to send a vec2. More... | |
void | sendUniform2v (const std::string &uniform, const float *data) |
Method to send a vec2. More... | |
void | sendUniform3v (const std::string &uniform, const std::vector< float > &data) |
Method to send a vec3. More... | |
void | sendUniform3v (const std::string &uniform, const float *data) |
Method to send a vec3. More... | |
void | sendUniform4v (const std::string &uniform, const std::vector< float > &data) |
Method to send a vec4. More... | |
void | sendUniform4v (const std::string &uniform, const float *data) |
Method to send a vec4. More... | |
void | sendUniform2iv (const std::string &uniform, const unsigned int *data) |
Method to send a ivec2. More... | |
void | sendUniform2iv (const std::string &uniform, const std::vector< unsigned int > &data) |
Method to send a ivec2. More... | |
void | sendUniform3iv (const std::string &uniform, const unsigned int *data) |
Method to send a ivec3. More... | |
void | sendUniform3iv (const std::string &uniform, const std::vector< unsigned int > &data) |
Method to send a ivec3. More... | |
void | sendUniform4iv (const std::string &uniform, const unsigned int *data) |
Method to send a ivec4. More... | |
void | sendUniform4iv (const std::string &uniform, const std::vector< unsigned int > &data) |
Method to send a ivec4. More... | |
void | sendUniform3m (const std::string &uniform, const std::vector< float > &data) |
Method to send a mat3. More... | |
void | sendUniform3m (const std::string &uniform, const float *data) |
Method to send a mat3. More... | |
void | sendUniform4m (const std::string &uniform, const std::vector< float > &data, bool inverse=false) |
Method to send a mat4. More... | |
void | sendUniform4m (const std::string &uniform, const float *data, bool inverse=false) |
Method to send a mat4. More... | |
void | create (void) |
Method to create program and attach all shaders. | |
bool | link (void) |
Method to link program and check status. | |
bool | isLinked (void) const |
void | autocatching (bool attributes=true, bool uniforms=true) |
Autocatching attributes and uniforms. More... | |
Protected Member Functions | |
void | _destroy () |
bool | _load (const std::string &file, int type) |
bool | _loadFromText (const std::string &source, int type) |
Class to manage shaders and programs.
Definition at line 48 of file ShaderProgram.h.
void reto::ShaderProgram::addAttribute | ( | const std::string & | attr | ) |
Method to catching an attribute value of a vertex shader.
attr | Attribute name |
void reto::ShaderProgram::addAttributes | ( | const std::vector< char * > | attrs | ) |
Method to catching an array of attribute values of a vertex shader.
attrs | Attribute vector names |
void reto::ShaderProgram::addUbo | ( | const std::string & | ubo | ) |
Method to catching an uniform buffer object.
ubo | Uniform Buffer Object name |
void reto::ShaderProgram::addUniform | ( | const std::string & | unifs | ) |
Method to catching an uniform value.
unifs | Uniform name |
void reto::ShaderProgram::addUniforms | ( | const std::vector< char * > | uniforms | ) |
Method to catching an array of uniform values.
uniforms | Uniform vector names |
int reto::ShaderProgram::attribute | ( | const std::string & | _attr | ) |
Method to get a attribute index in cache.
_attr | Attribute name |
void reto::ShaderProgram::autocatching | ( | bool | attributes = true , |
bool | uniforms = true |
||
) |
Autocatching attributes and uniforms.
attributes | Autocatching attributes (default= true) |
uniforms | Autocatching attributes (default= true) |
void reto::ShaderProgram::bindAttribute | ( | const std::string & | attr, |
unsigned int | index | ||
) |
Method to bind a specific index to a attribute value.
attr | Attribute name |
index | Attribute index |
void reto::ShaderProgram::bindUniform | ( | const std::string & | unif, |
unsigned int | index | ||
) |
Method to bind a specific index to a uniform value.
unif | Uniform name |
index | Uniform index |
bool reto::ShaderProgram::compileAndLink | ( | void | ) |
Method to compile a program.
bool reto::ShaderProgram::isAttributeCached | ( | const std::string & | attr | ) | const |
Method to check if attribute exist (only check in attribute cache)
attr | Attribute name |
bool reto::ShaderProgram::isUniformCached | ( | const std::string & | unif | ) | const |
Method to check if uniform exist (only check in uniform cache)
unif | Uniform name |
bool reto::ShaderProgram::load | ( | const std::string & | vsFile, |
const std::string & | fsFile | ||
) |
Method to load and add a vertex and fragment shaders from file.
vsFile | Vertex shader file source |
fsFile | Fragment shader source |
bool reto::ShaderProgram::loadFragmentShader | ( | const std::string & | file | ) |
Method to load and add a fragment shader from file.
file | Shader file source |
bool reto::ShaderProgram::loadFragmentShaderFromText | ( | const std::string & | source | ) |
Method to load and add a fragment shader from text.
source | Shader source |
bool reto::ShaderProgram::loadFromText | ( | const std::string & | vsSource, |
const std::string & | fsSource | ||
) |
Method to load and add a vertex and fragment shaders from text.
vsSource | Vertex shader source |
fsSource | Fragment shader source |
bool reto::ShaderProgram::loadVertexShader | ( | const std::string & | file | ) |
Method to load and add a vertex shader from file.
file | Shader file source |
bool reto::ShaderProgram::loadVertexShaderFromText | ( | const std::string & | source | ) |
Method to load and add a vertex shader from text.
source | Shader source |
int reto::ShaderProgram::operator() | ( | const std::string & | _attr | ) |
Method to get a attribute index in cache.
_attr | Attribute name |
int reto::ShaderProgram::operator[] | ( | const std::string & | _unif | ) |
Method to get a uniform index in cache.
_unif | Uniform name |
unsigned int reto::ShaderProgram::program | ( | void | ) |
Method to get Program id.
void reto::ShaderProgram::sendUniform | ( | const std::string & | uniform, |
float | x, | ||
float | y, | ||
float | z | ||
) |
Method to send a vec3 with separated data.
uniform | Uniform name |
x | First element |
y | Second element |
z | Third element |
void reto::ShaderProgram::sendUniform2iv | ( | const std::string & | uniform, |
const unsigned int * | data | ||
) |
Method to send a ivec2.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform2iv | ( | const std::string & | uniform, |
const std::vector< unsigned int > & | data | ||
) |
Method to send a ivec2.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform2v | ( | const std::string & | uniform, |
const std::vector< float > & | data | ||
) |
Method to send a vec2.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform2v | ( | const std::string & | uniform, |
const float * | data | ||
) |
Method to send a vec2.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform3iv | ( | const std::string & | uniform, |
const unsigned int * | data | ||
) |
Method to send a ivec3.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform3iv | ( | const std::string & | uniform, |
const std::vector< unsigned int > & | data | ||
) |
Method to send a ivec3.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform3m | ( | const std::string & | uniform, |
const std::vector< float > & | data | ||
) |
Method to send a mat3.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform3m | ( | const std::string & | uniform, |
const float * | data | ||
) |
Method to send a mat3.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform3v | ( | const std::string & | uniform, |
const std::vector< float > & | data | ||
) |
Method to send a vec3.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform3v | ( | const std::string & | uniform, |
const float * | data | ||
) |
Method to send a vec3.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform4iv | ( | const std::string & | uniform, |
const unsigned int * | data | ||
) |
Method to send a ivec4.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform4iv | ( | const std::string & | uniform, |
const std::vector< unsigned int > & | data | ||
) |
Method to send a ivec4.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform4m | ( | const std::string & | uniform, |
const std::vector< float > & | data, | ||
bool | inverse = false |
||
) |
Method to send a mat4.
uniform | Uniform name |
data | Data |
inverse | Specifies whether to transpose the matrix as the values are loaded into the uniform variable |
void reto::ShaderProgram::sendUniform4m | ( | const std::string & | uniform, |
const float * | data, | ||
bool | inverse = false |
||
) |
Method to send a mat4.
uniform | Uniform name |
data | Data |
inverse | Specifies whether to transpose the matrix as the values are loaded into the uniform variable |
void reto::ShaderProgram::sendUniform4v | ( | const std::string & | uniform, |
const std::vector< float > & | data | ||
) |
Method to send a vec4.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniform4v | ( | const std::string & | uniform, |
const float * | data | ||
) |
Method to send a vec4.
uniform | Uniform name |
data | Data |
void reto::ShaderProgram::sendUniformb | ( | const std::string & | uniform, |
bool | val | ||
) |
Method to send a boolean.
uniform | Uniform name |
val | Boolean data |
void reto::ShaderProgram::sendUniformf | ( | const std::string & | uniform, |
float | val | ||
) |
Method to send a float.
uniform | Uniform name |
val | Float data |
void reto::ShaderProgram::sendUniformi | ( | const std::string & | uniform, |
int | val | ||
) |
Method to send an integer.
uniform | Uniform name |
val | Int data |
void reto::ShaderProgram::sendUniformu | ( | const std::string & | uniform, |
unsigned int | val | ||
) |
Method to send an unsigned integer.
uniform | Uniform name |
val | Unsigned integer data |
int reto::ShaderProgram::subprogram | ( | const std::string & | name, |
int | shaderType | ||
) |
Method to get a subprogram index of a specific kind of shader in cache.
name | Subprogram name |
shaderType | OpenGL Shader type |
int reto::ShaderProgram::ubo | ( | const std::string & | ubo | ) |
Method to get a Uniform Buffer Object index in cache.
ubo | Uniform Buffer Object name |
int reto::ShaderProgram::uniform | ( | const std::string & | _unif | ) |
Method to get a uniform index in cache.
_unif | Uniform name |