GLProgram Class that implements a glProgram. More...
#include <CCGLProgram.h>
Classes | |
struct | flag_struct |
Public Types | |
enum | { VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_COLOR, VERTEX_ATTRIB_TEX_COORD, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_MAX, VERTEX_ATTRIB_TEX_COORDS = VERTEX_ATTRIB_TEX_COORD } |
enum | { UNIFORM_P_MATRIX, UNIFORM_MV_MATRIX, UNIFORM_MVP_MATRIX, UNIFORM_TIME, UNIFORM_SIN_TIME, UNIFORM_COS_TIME, UNIFORM_RANDOM01, UNIFORM_SAMPLER0, UNIFORM_SAMPLER1, UNIFORM_SAMPLER2, UNIFORM_SAMPLER3, UNIFORM_MAX } |
Public Member Functions | |
GLProgram () | |
virtual | ~GLProgram () |
bool | initWithPrecompiledProgramByteArray (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray) |
bool | initWithByteArrays (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray) |
bool | initWithFilenames (const std::string &vShaderFilename, const std::string &fShaderFilename) |
Uniform * | getUniform (const std::string &name) |
VertexAttrib * | getVertexAttrib (const std::string &name) |
void | bindAttribLocation (const std::string &attributeName, GLuint index) const |
It will add a new attribute to the shader by calling glBindAttribLocation. More... | |
GLint | getAttribLocation (const std::string &attributeName) const |
calls glGetAttribLocation More... | |
GLint | getUniformLocation (const std::string &attributeName) const |
calls glGetUniformLocation() More... | |
bool | link () |
links the glProgram More... | |
void | use () |
it will call glUseProgram() More... | |
void | updateUniforms () |
It will create 4 uniforms: More... | |
GLint | getUniformLocationForName (const char *name) const |
calls retrieves the named uniform location for this shader program. More... | |
void | setUniformLocationWith1i (GLint location, GLint i1) |
calls glUniform1i only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith2i (GLint location, GLint i1, GLint i2) |
calls glUniform2i only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith3i (GLint location, GLint i1, GLint i2, GLint i3) |
calls glUniform3i only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith4i (GLint location, GLint i1, GLint i2, GLint i3, GLint i4) |
calls glUniform4i only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith2iv (GLint location, GLint *ints, unsigned int numberOfArrays) |
calls glUniform2iv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith3iv (GLint location, GLint *ints, unsigned int numberOfArrays) |
calls glUniform3iv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith4iv (GLint location, GLint *ints, unsigned int numberOfArrays) |
calls glUniform4iv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith1f (GLint location, GLfloat f1) |
calls glUniform1f only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith2f (GLint location, GLfloat f1, GLfloat f2) |
calls glUniform2f only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith3f (GLint location, GLfloat f1, GLfloat f2, GLfloat f3) |
calls glUniform3f only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith4f (GLint location, GLfloat f1, GLfloat f2, GLfloat f3, GLfloat f4) |
calls glUniform4f only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith2fv (GLint location, const GLfloat *floats, unsigned int numberOfArrays) |
calls glUniform2fv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith3fv (GLint location, const GLfloat *floats, unsigned int numberOfArrays) |
calls glUniform3fv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWith4fv (GLint location, const GLfloat *floats, unsigned int numberOfArrays) |
calls glUniform4fv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWithMatrix2fv (GLint location, const GLfloat *matrixArray, unsigned int numberOfMatrices) |
calls glUniformMatrix2fv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWithMatrix3fv (GLint location, const GLfloat *matrixArray, unsigned int numberOfMatrices) |
calls glUniformMatrix3fv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformLocationWithMatrix4fv (GLint location, const GLfloat *matrixArray, unsigned int numberOfMatrices) |
calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program. More... | |
void | setUniformsForBuiltins () |
will update the builtin uniforms if they are different than the previous call for this same shader program. More... | |
void | setUniformsForBuiltins (const Mat4 &modelView) |
std::string | getVertexShaderLog () const |
returns the vertexShader error log More... | |
std::string | getFragmentShaderLog () const |
returns the fragmentShader error log More... | |
std::string | getProgramLog () const |
returns the program error log More... | |
void | reset () |
const GLuint | getProgram () const |
CC_DEPRECATED_ATTRIBUTE bool | initWithVertexShaderByteArray (const GLchar *vertexByteArray, const GLchar *fragByteArray) |
CC_DEPRECATED_ATTRIBUTE bool | initWithVertexShaderFilename (const std::string &vertexFilename, const std::string &fragFilename) |
CC_DEPRECATED_ATTRIBUTE void | addAttribute (const std::string &attributeName, GLuint index) const |
![]() | |
void | retain () |
Retains the ownership. More... | |
void | release () |
Releases the ownership immediately. More... | |
Ref * | autorelease () |
Releases the ownership sometime soon automatically. More... | |
unsigned int | getReferenceCount () const |
Returns the Ref's current reference count. More... | |
virtual | ~Ref () |
Static Public Member Functions | |
static GLProgram * | createWithPrecompiledProgramByteArray (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray) |
Initializes the GLProgram with a vertex and fragment with bytes array. More... | |
static GLProgram * | createWithByteArrays (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray) |
Initializes the GLProgram with a vertex and fragment with bytes array. More... | |
static GLProgram * | createWithFilenames (const std::string &vShaderFilename, const std::string &fShaderFilename) |
Initializes the GLProgram with a vertex and fragment with contents of filenames. More... | |
Protected Member Functions | |
bool | updateUniformLocation (GLint location, const GLvoid *data, unsigned int bytes) |
virtual std::string | getDescription () const |
void | bindPredefinedVertexAttribs () |
void | parseVertexAttribs () |
void | parseUniforms () |
bool | compileShader (GLuint *shader, GLenum type, const GLchar *source) |
std::string | logForOpenGLObject (GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const |
![]() | |
Ref () | |
Constructor. More... | |
Protected Attributes | |
GLuint | _program |
GLuint | _vertShader |
GLuint | _fragShader |
GLint | _builtInUniforms [UNIFORM_MAX] |
struct _hashUniformEntry * | _hashForUniforms |
bool | _hasShaderCompiler |
std::string | _shaderId |
struct cocos2d::GLProgram::flag_struct | _flags |
std::unordered_map < std::string, Uniform > | _userUniforms |
std::unordered_map < std::string, VertexAttrib > | _vertexAttribs |
![]() | |
unsigned int | _referenceCount |
count of references More... | |
Friends | |
class | GLProgramState |
GLProgram Class that implements a glProgram.