cocos2d-x  3.3rc0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
GLProgram Class Reference

GLProgram Class that implements a glProgram. More...

#include <CCGLProgram.h>

Inheritance diagram for GLProgram:
Ref

Classes

struct  flag_struct
 

Public Types

enum  {
  VERTEX_ATTRIB_POSITION, VERTEX_ATTRIB_COLOR, VERTEX_ATTRIB_TEX_COORD, VERTEX_ATTRIB_TEX_COORD1,
  VERTEX_ATTRIB_TEX_COORD2, VERTEX_ATTRIB_TEX_COORD3, VERTEX_ATTRIB_NORMAL, VERTEX_ATTRIB_BLEND_WEIGHT,
  VERTEX_ATTRIB_BLEND_INDEX, VERTEX_ATTRIB_MAX, VERTEX_ATTRIB_TEX_COORDS = VERTEX_ATTRIB_TEX_COORD
}
 
enum  {
  UNIFORM_AMBIENT_COLOR, UNIFORM_P_MATRIX, UNIFORM_MV_MATRIX, UNIFORM_MVP_MATRIX,
  UNIFORM_NORMAL_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 ()
local ~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)
UniformgetUniform (const std::string &name)
VertexAttribgetVertexAttrib (const std::string &name)
var getVertexAttrib ( var name)
local getVertexAttrib ( local name)
void bindAttribLocation (const std::string &attributeName, GLuint index) const
 It will add a new attribute to the shader by calling glBindAttribLocation. More...
 
var bindAttribLocation ( var attributeName, var index)
 It will add a new attribute to the shader by calling glBindAttribLocation. More...
 
local bindAttribLocation ( local attributeName, local index)
 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...
 
var link ()
 links the glProgram More...
 
local link ()
 links the glProgram More...
 
void use ()
 it will call glUseProgram() More...
 
void updateUniforms ()
 It will create 4 uniforms: More...
 
var updateUniforms ()
 It will create 4 uniforms: More...
 
local updateUniforms ()
 It will create 4 uniforms: More...
 
GLint getUniformLocationForName (const char *name) const
 calls retrieves the named uniform location for this shader program. More...
 
local getUniformLocationForName ( local name)
 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...
 
var setUniformLocationI32 ( var location, var i1)
 calls glUniform1i only if the values are different than the previous call for this same shader program. More...
 
local setUniformLocationI32 ( local location, local 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...
 
var setUniformLocationWith2i ( var location, var i1, var i2)
 calls glUniform2i only if the values are different than the previous call for this same shader program. More...
 
local setUniformLocationWith2i ( local location, local i1, local 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...
 
var setUniformLocationWith3iv ( var location, var ints, var numberOfArrays)
 calls glUniform3iv only if the values are different than the previous call for this same shader program. More...
 
local setUniformLocationWith3iv ( local location, local ints, local 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...
 
var setUniformLocationWith4iv ( var location, var ints, var numberOfArrays)
 calls glUniform4iv only if the values are different than the previous call for this same shader program. More...
 
local setUniformLocationWith4iv ( local location, local ints, local 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...
 
local setUniformLocationWith1f ( local location, local 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...
 
local setUniformLocationWith2f ( local location, local f1, local 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...
 
local setUniformLocationWith3f ( local location, local f1, local f2, local 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 setUniformLocationWith1fv (GLint location, const GLfloat *floats, unsigned int numberOfArrays)
 calls glUniformfv 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)
var setUniformsForBuiltins ( var modelView)
local setUniformsForBuiltins ( local modelView)
std::string getVertexShaderLog () const
 returns the vertexShader error log More...
 
var getVertexShaderLog ()
 returns the vertexShader error log More...
 
local getVertexShaderLog ()
 returns the vertexShader error log More...
 
std::string getFragmentShaderLog () const
 returns the fragmentShader error log More...
 
var getFragmentShaderLog ()
 returns the fragmentShader error log More...
 
local getFragmentShaderLog ()
 returns the fragmentShader error log More...
 
std::string getProgramLog () const
 returns the program error log More...
 
var getProgramLog ()
 returns the program error log More...
 
local getProgramLog ()
 returns the program error log More...
 
void reset ()
const GLuint getProgram () const
var getProgram ()
local getProgram ()
bool initWithVertexShaderByteArray (const GLchar *vertexByteArray, const GLchar *fragByteArray)
var initWithVertexShaderByteArray ( var vertexByteArray, var fragByteArray)
local initWithVertexShaderByteArray ( local vertexByteArray, local fragByteArray)
bool initWithVertexShaderFilename (const std::string &vertexFilename, const std::string &fragFilename)
void addAttribute (const std::string &attributeName, GLuint index) const
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
local getReferenceCount ()
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()

Static Public Member Functions

static GLProgramcreateWithPrecompiledProgramByteArray (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 Initializes the GLProgram with a vertex and fragment with bytes array. More...
 
local initWithString ( local vShaderByteArray, local fShaderByteArray)
 Initializes the GLProgram with a vertex and fragment with bytes array. More...
 
static GLProgramcreateWithByteArrays (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 Initializes the GLProgram with a vertex and fragment with bytes array. More...
 
static GLProgramcreateWithFilenames (const std::string &vShaderFilename, const std::string &fShaderFilename)
 Initializes the GLProgram with a vertex and fragment with contents of filenames. More...
 

Static Public Attributes

static const char * SHADER_NAME_POSITION_TEXTURE_COLOR
static const char * SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP
static const char * SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST
var SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST
local SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST
static const char * SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV
static const char * SHADER_NAME_POSITION_COLOR
var SHADER_NAME_POSITION_COLOR
local SHADER_NAME_POSITION_COLOR
static const char * SHADER_NAME_POSITION_COLOR_NO_MVP
static const char * SHADER_NAME_POSITION_TEXTURE
var SHADER_NAME_POSITION_TEXTURE
local SHADER_NAME_POSITION_TEXTURE
static const char * SHADER_NAME_POSITION_TEXTURE_U_COLOR
static const char * SHADER_NAME_POSITION_TEXTURE_A8_COLOR
var SHADER_NAME_POSITION_TEXTURE_A8_COLOR
local SHADER_NAME_POSITION_TEXTURE_A8_COLOR
static const char * SHADER_NAME_POSITION_U_COLOR
var SHADER_NAME_POSITION_U_COLOR
local SHADER_NAME_POSITION_U_COLOR
static const char * SHADER_NAME_POSITION_LENGTH_TEXTURE_COLOR
static const char * SHADER_NAME_LABEL_NORMAL
var SHADER_NAME_LABEL_NORMAL
local SHADER_NAME_LABEL_NORMAL
static const char * SHADER_NAME_LABEL_OUTLINE
var SHADER_NAME_LABEL_OUTLINE
local SHADER_NAME_LABEL_OUTLINE
static const char * SHADER_NAME_LABEL_DISTANCEFIELD_NORMAL
static const char * SHADER_NAME_LABEL_DISTANCEFIELD_GLOW
var SHADER_NAME_LABEL_DISTANCEFIELD_GLOW
local SHADER_NAME_LABEL_DISTANCEFIELD_GLOW
static const char * SHADER_3D_POSITION
var SHADER_3D_POSITION
local SHADER_3D_POSITION
static const char * SHADER_3D_POSITION_TEXTURE
var SHADER_3D_POSITION_TEXTURE
local SHADER_3D_POSITION_TEXTURE
static const char * SHADER_3D_SKINPOSITION_TEXTURE
var SHADER_3D_SKINPOSITION_TEXTURE
local SHADER_3D_SKINPOSITION_TEXTURE
static const char * SHADER_3D_POSITION_NORMAL
var SHADER_3D_POSITION_NORMAL
local SHADER_3D_POSITION_NORMAL
static const char * SHADER_3D_POSITION_NORMAL_TEXTURE
static const char * SHADER_3D_SKINPOSITION_NORMAL_TEXTURE
static const char * UNIFORM_NAME_AMBIENT_COLOR
var UNIFORM_NAME_AMBIENT_COLOR
local UNIFORM_NAME_AMBIENT_COLOR
static const char * UNIFORM_NAME_P_MATRIX
var UNIFORM_NAME_P_MATRIX
local UNIFORM_NAME_P_MATRIX
static const char * UNIFORM_NAME_MV_MATRIX
var UNIFORM_NAME_MV_MATRIX
local UNIFORM_NAME_MV_MATRIX
static const char * UNIFORM_NAME_MVP_MATRIX
var UNIFORM_NAME_MVP_MATRIX
local UNIFORM_NAME_MVP_MATRIX
static const char * UNIFORM_NAME_NORMAL_MATRIX
var UNIFORM_NAME_NORMAL_MATRIX
local UNIFORM_NAME_NORMAL_MATRIX
static const char * UNIFORM_NAME_TIME
var UNIFORM_NAME_TIME
local UNIFORM_NAME_TIME
static const char * UNIFORM_NAME_SIN_TIME
var UNIFORM_NAME_SIN_TIME
local UNIFORM_NAME_SIN_TIME
static const char * UNIFORM_NAME_COS_TIME
var UNIFORM_NAME_COS_TIME
local UNIFORM_NAME_COS_TIME
static const char * UNIFORM_NAME_RANDOM01
var UNIFORM_NAME_RANDOM01
local UNIFORM_NAME_RANDOM01
static const char * UNIFORM_NAME_SAMPLER0
var UNIFORM_NAME_SAMPLER0
local UNIFORM_NAME_SAMPLER0
static const char * UNIFORM_NAME_SAMPLER1
var UNIFORM_NAME_SAMPLER1
local UNIFORM_NAME_SAMPLER1
static const char * UNIFORM_NAME_SAMPLER2
var UNIFORM_NAME_SAMPLER2
local UNIFORM_NAME_SAMPLER2
static const char * UNIFORM_NAME_SAMPLER3
var UNIFORM_NAME_SAMPLER3
local UNIFORM_NAME_SAMPLER3
static const char * UNIFORM_NAME_ALPHA_TEST_VALUE
var UNIFORM_NAME_ALPHA_TEST_VALUE
local UNIFORM_NAME_ALPHA_TEST_VALUE
static const char * ATTRIBUTE_NAME_COLOR
var ATTRIBUTE_NAME_COLOR
local ATTRIBUTE_NAME_COLOR
static const char * ATTRIBUTE_NAME_POSITION
var ATTRIBUTE_NAME_POSITION
local ATTRIBUTE_NAME_POSITION
static const char * ATTRIBUTE_NAME_TEX_COORD
var ATTRIBUTE_NAME_TEX_COORD
local ATTRIBUTE_NAME_TEX_COORD
static const char * ATTRIBUTE_NAME_TEX_COORD1
var ATTRIBUTE_NAME_TEX_COORD1
local ATTRIBUTE_NAME_TEX_COORD1
static const char * ATTRIBUTE_NAME_TEX_COORD2
var ATTRIBUTE_NAME_TEX_COORD2
local ATTRIBUTE_NAME_TEX_COORD2
static const char * ATTRIBUTE_NAME_TEX_COORD3
var ATTRIBUTE_NAME_TEX_COORD3
local ATTRIBUTE_NAME_TEX_COORD3
static const char * ATTRIBUTE_NAME_NORMAL
var ATTRIBUTE_NAME_NORMAL
local ATTRIBUTE_NAME_NORMAL
static const char * ATTRIBUTE_NAME_BLEND_WEIGHT
var ATTRIBUTE_NAME_BLEND_WEIGHT
local ATTRIBUTE_NAME_BLEND_WEIGHT
static const char * ATTRIBUTE_NAME_BLEND_INDEX
var ATTRIBUTE_NAME_BLEND_INDEX
local ATTRIBUTE_NAME_BLEND_INDEX

Protected Member Functions

bool updateUniformLocation (GLint location, const GLvoid *data, unsigned int bytes)
var updateUniformLocation ( var location, var data, var bytes)
local updateUniformLocation ( local location, local data, local bytes)
virtual std::string getDescription () const
var getDescription ()
local getDescription ()
void bindPredefinedVertexAttribs ()
var bindPredefinedVertexAttribs ()
local bindPredefinedVertexAttribs ()
void parseVertexAttribs ()
var parseVertexAttribs ()
local parseVertexAttribs ()
void parseUniforms ()
var parseUniforms ()
local parseUniforms ()
bool compileShader (GLuint *shader, GLenum type, const GLchar *source)
var compileShader ( var shader, var type, var source)
local compileShader ( local shader, local type, local source)
std::string logForOpenGLObject (GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc) const
local logForOpenGLObject ( local object, local infoFunc, local logFunc)
- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 
 Ref ()
 Constructor. More...
 

Protected Attributes

GLuint _program
GLuint _vertShader
var _vertShader
local _vertShader
GLuint _fragShader
var _fragShader
local _fragShader
GLint _builtInUniforms [UNIFORM_MAX]
var _builtInUniforms ()
local _builtInUniforms ()
struct _hashUniformEntry * _hashForUniforms
var _hashForUniforms
local _hashForUniforms
bool _hasShaderCompiler
var _hasShaderCompiler
local _hasShaderCompiler
std::string _shaderId
local _shaderId
struct
cocos2d::GLProgram::flag_struct 
_flags
var _flags
local _flags
std::unordered_map
< std::string, Uniform
_userUniforms
var _userUniforms
local _userUniforms
std::unordered_map
< std::string, VertexAttrib
_vertexAttribs
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 
local _referenceCount
 count of references More...
 

Friends

class GLProgramState

Detailed Description

GLProgram Class that implements a glProgram.

Since
v2.0.0

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