cocos2d-x  2.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCGLProgram Class Reference

CCGLProgram Class that implements a glProgram. More...

#include <CCGLProgram.h>

Inheritance diagram for CCGLProgram:
CCObject CCCopying

Public Member Functions

 CCGLProgram ()
virtual ~CCGLProgram ()
bool initWithVertexShaderByteArray (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 Initializes the CCGLProgram with a vertex and fragment with bytes array. More...
 
var initWithString ( var vShaderByteArray, var fShaderByteArray)
 Initializes the CCGLProgram with a vertex and fragment with bytes array. More...
 
bool initWithPrecompiledProgramByteArray (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 Initializes the CCGLProgram with precompiled shader program. More...
 
bool initWithVertexShaderFilename (const char *vShaderFilename, const char *fShaderFilename)
 Initializes the CCGLProgram with a vertex and fragment with contents of filenames. More...
 
void addAttribute (const char *attributeName, GLuint index)
 It will add a new attribute to the shader. More...
 
bool link ()
 links the glProgram More...
 
var link ()
 links the glProgram More...
 
void use ()
 it will call glUseProgram() More...
 
var use ()
 it will call glUseProgram() More...
 
void updateUniforms ()
 It will create 4 uniforms: More...
 
var updateUniforms ()
 It will create 4 uniforms: More...
 
GLint getUniformLocationForName (const char *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...
 
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...
 
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...
 
var setUniformLocationWith3i ( var location, var i1, var i2, var 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...
 
var setUniformLocationWith4i ( var location, var i1, var i2, var i3, var 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...
 
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...
 
void setUniformLocationWith1f (GLint location, GLfloat f1)
 calls glUniform1f only if the values are different than the previous call for this same shader program. More...
 
var setUniformLocationF32 ( var location, var 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...
 
var setUniformLocationF32 ( var location, var f1, var f2, var 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, 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, 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, GLfloat *floats, unsigned int numberOfArrays)
 calls glUniform4fv only if the values are different than the previous call for this same shader program. More...
 
void setUniformLocationWithMatrix4fv (GLint location, 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...
 
const char * vertexShaderLog ()
 returns the vertexShader error log More...
 
const char * fragmentShaderLog ()
 returns the fragmentShader error log More...
 
const char * programLog ()
 returns the program error log More...
 
var getProgramLog ()
 returns the program error log More...
 
void reset ()
 reload all shaders, this function is designed for android when opengl context lost, so don't call it. More...
 
const GLuint getProgram ()
var getProgram ()
- Public Member Functions inherited from CCObject
 CCObject (void)
virtual ~CCObject (void)
void release (void)
void retain (void)
CCObjectautorelease (void)
CCObjectcopy (void)
bool isSingleReference (void) const
unsigned int retainCount (void) const
virtual bool isEqual (const CCObject *pObject)
virtual void acceptVisitor (CCDataVisitor &visitor)
virtual void update (float dt)
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
int m_nLuaID
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

Detailed Description

CCGLProgram Class that implements a glProgram.

Since
v2.0.0

Constructor & Destructor Documentation

var ctor ( )
virtual ~CCGLProgram ( )
virtual

Member Function Documentation

void addAttribute ( const char *  attributeName,
GLuint  index 
)

It will add a new attribute to the shader.

var addAttribute ( var  attributeName,
var  index 
)

It will add a new attribute to the shader.

const char* fragmentShaderLog ( )

returns the fragmentShader error log

var getFragmentShaderLog ( )

returns the fragmentShader error log

const GLuint getProgram ( )
inline
var getProgram ( )
inline
GLint getUniformLocationForName ( const char *  name)

calls retrieves the named uniform location for this shader program.

var getUniformLocationForName ( var  name)

calls retrieves the named uniform location for this shader program.

bool
initWithPrecompiledProgramByteArray
( const GLchar vShaderByteArray,
const GLchar fShaderByteArray 
)

Initializes the CCGLProgram with precompiled shader program.

var
initWithPrecompiledProgramByteArray
( var  vShaderByteArray,
var  fShaderByteArray 
)

Initializes the CCGLProgram with precompiled shader program.

local
initWithPrecompiledProgramByteArray
( local  vShaderByteArray,
local  fShaderByteArray 
)

Initializes the CCGLProgram with precompiled shader program.

bool initWithVertexShaderByteArray ( const GLchar vShaderByteArray,
const GLchar fShaderByteArray 
)

Initializes the CCGLProgram with a vertex and fragment with bytes array.

var initWithString ( var  vShaderByteArray,
var  fShaderByteArray 
)

Initializes the CCGLProgram with a vertex and fragment with bytes array.

bool initWithVertexShaderFilename ( const char *  vShaderFilename,
const char *  fShaderFilename 
)

Initializes the CCGLProgram with a vertex and fragment with contents of filenames.

var init ( var  vShaderFilename,
var  fShaderFilename 
)

Initializes the CCGLProgram with a vertex and fragment with contents of filenames.

bool link ( )

links the glProgram

var link ( )

links the glProgram

const char* programLog ( )

returns the program error log

var getProgramLog ( )

returns the program error log

void reset ( )

reload all shaders, this function is designed for android when opengl context lost, so don't call it.

var reset ( )

reload all shaders, this function is designed for android when opengl context lost, so don't call it.

void setUniformLocationWith1f ( GLint  location,
GLfloat  f1 
)

calls glUniform1f only if the values are different than the previous call for this same shader program.

var setUniformLocationF32 ( var  location,
var  f1 
)

calls glUniform1f only if the values are different than the previous call for this same shader program.

void setUniformLocationWith1i ( GLint  location,
GLint  i1 
)

calls glUniform1i only if the values are different than the previous call for this same shader program.

var setUniformLocationI32 ( var  location,
var  i1 
)

calls glUniform1i only if the values are different than the previous call for this same shader program.

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.

var setUniformLocationF32 ( var  location,
var  f1,
var  f2 
)

calls glUniform2f only if the values are different than the previous call for this same shader program.

void setUniformLocationWith2fv ( GLint  location,
GLfloat *  floats,
unsigned int  numberOfArrays 
)

calls glUniform2fv only if the values are different than the previous call for this same shader program.

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.

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.

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.

var setUniformLocationWith2iv ( var  location,
var  ints,
var  numberOfArrays 
)

calls glUniform2iv only if the values are different than the previous call for this same shader program.

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.

var setUniformLocationF32 ( var  location,
var  f1,
var  f2,
var  f3 
)

calls glUniform3f only if the values are different than the previous call for this same shader program.

void setUniformLocationWith3fv ( GLint  location,
GLfloat *  floats,
unsigned int  numberOfArrays 
)

calls glUniform3fv only if the values are different than the previous call for this same shader program.

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.

var setUniformLocationWith3i ( var  location,
var  i1,
var  i2,
var  i3 
)

calls glUniform3i only if the values are different than the previous call for this same shader program.

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.

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.

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.

var setUniformLocationF32 ( var  location,
var  f1,
var  f2,
var  f3,
var  f4 
)

calls glUniform4f only if the values are different than the previous call for this same shader program.

void setUniformLocationWith4fv ( GLint  location,
GLfloat *  floats,
unsigned int  numberOfArrays 
)

calls glUniform4fv only if the values are different than the previous call for this same shader program.

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.

var setUniformLocationWith4i ( var  location,
var  i1,
var  i2,
var  i3,
var  i4 
)

calls glUniform4i only if the values are different than the previous call for this same shader program.

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.

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.

void
setUniformLocationWithMatrix4fv
( GLint  location,
GLfloat *  matrixArray,
unsigned int  numberOfMatrices 
)

calls glUniformMatrix4fv only if the values are different than the previous call for this same shader program.

void setUniformsForBuiltins ( )

will update the builtin uniforms if they are different than the previous call for this same shader program.

var setUniformsForBuiltins ( )

will update the builtin uniforms if they are different than the previous call for this same shader program.

void updateUniforms ( )

It will create 4 uniforms:

  • kCCUniformPMatrix
  • kCCUniformMVMatrix
  • kCCUniformMVPMatrix
  • kCCUniformSampler

And it will bind "kCCUniformSampler" to 0

var updateUniforms ( )

It will create 4 uniforms:

  • kCCUniformPMatrix
  • kCCUniformMVMatrix
  • kCCUniformMVPMatrix
  • kCCUniformSampler

And it will bind "kCCUniformSampler" to 0

void use ( )

it will call glUseProgram()

var use ( )

it will call glUseProgram()

const char* vertexShaderLog ( )

returns the vertexShader error log

var getVertexShaderLog ( )

returns the vertexShader error log


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