cocos2d-x  2.2.3-gd2.113-rev1ec524e
Loading...
Searching...
No Matches
CCGLProgram Class Reference

CCGLProgram Class that implements a glProgram. More...

#include <CCGLProgram.h>

Inheritance diagram for CCGLProgram:
[legend]
Collaboration diagram for CCGLProgram:
[legend]

Public Member Functions

 CCGLProgram ()
 ctor NA More...
 
virtual ~CCGLProgram ()
 NA NA. More...
 
bool initWithVertexShaderByteArray (const GLchar *vShaderByteArray, const GLchar *fShaderByteArray)
 Initializes the CCGLProgram with a vertex and fragment with bytes array initWithString NA. 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 init NA. More...
 
void addAttribute (const char *attributeName, GLuint index)
 It will add a new attribute to the shader NA. More...
 
bool link ()
 links the glProgram NA More...
 
void use ()
 it will call glUseProgram() NA More...
 
void 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...
 
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, 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 getVertexShaderLog NA More...
 
const char * fragmentShaderLog ()
 returns the fragmentShader error log getFragmentShaderLog NA More...
 
const char * programLog ()
 returns the program error log getProgramLog NA 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 ()
 NA. More...
 
- Public Member Functions inherited from CCObject
 CCObject (void)
 
virtual ~CCObject (void)
 NA. More...
 
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)
 
 CCObject (const CCObject &)
 
CCObjectoperator= (const CCObject &)
 
virtual void encodeWithCoder (DS_Dictionary *)
 
virtual bool canEncode ()
 
CCObjectType getObjType () const
 
virtual int getTag () const
 
virtual void setTag (int nTag)
 
void setObjType (CCObjectType)
 
- Public Member Functions inherited from CCCopying
virtual CCObjectcopyWithZone (CCZone *pZone)
 

Protected Member Functions

bool updateUniformLocation (GLint location, GLvoid *data, unsigned int bytes)
 
const char * description ()
 
bool compileShader (GLuint *shader, GLenum type, const GLchar *source)
 
const char * logForOpenGLObject (GLuint object, GLInfoFunction infoFunc, GLLogFunction logFunc)
 

Protected Attributes

GLuint m_uProgram
 
GLuint m_uVertShader
 
GLuint m_uFragShader
 
GLint m_uUniforms [kCCUniform_MAX]
 
struct _hashUniformEntry * m_pHashForUniforms
 
bool m_bUsesTime
 
bool m_hasShaderCompiler
 
std::string m_shaderId
 
- Protected Attributes inherited from CCObject
unsigned int m_uReference
 
unsigned int m_uAutoReleaseCount
 
int m_nTag
 
int m_eObjType
 
unsigned int m_uObjectIdxInArray
 

Additional Inherited Members

- Static Public Member Functions inherited from CCObject
static CCObjectcreateWithCoder (DS_Dictionary *)
 
- Public Attributes inherited from CCObject
unsigned int m_uID
 
int m_nLuaID
 

Detailed Description

CCGLProgram Class that implements a glProgram.

Since
v2.0.0

Constructor & Destructor Documentation

◆ CCGLProgram()

ctor NA

◆ ~CCGLProgram()

virtual ~CCGLProgram ( )
virtual

NA NA.

Member Function Documentation

◆ addAttribute()

void addAttribute ( const char *  attributeName,
GLuint  index 
)

It will add a new attribute to the shader NA.

◆ compileShader()

bool compileShader ( GLuint *  shader,
GLenum  type,
const GLchar source 
)
protected

◆ description()

const char * description ( )
protected

◆ fragmentShaderLog()

const char * fragmentShaderLog ( )

returns the fragmentShader error log getFragmentShaderLog NA

◆ getProgram()

const GLuint getProgram ( )
inline

NA.

◆ getUniformLocationForName()

GLint getUniformLocationForName ( const char *  name)

calls retrieves the named uniform location for this shader program.

NA

◆ initWithPrecompiledProgramByteArray()

bool initWithPrecompiledProgramByteArray ( const GLchar vShaderByteArray,
const GLchar fShaderByteArray 
)

Initializes the CCGLProgram with precompiled shader program.

◆ initWithVertexShaderByteArray()

bool initWithVertexShaderByteArray ( const GLchar vShaderByteArray,
const GLchar fShaderByteArray 
)

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

◆ initWithVertexShaderFilename()

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

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

◆ link()

bool link ( )

links the glProgram NA

◆ logForOpenGLObject()

const char * logForOpenGLObject ( GLuint  object,
GLInfoFunction  infoFunc,
GLLogFunction  logFunc 
)
protected

◆ programLog()

const char * programLog ( )

returns the program error log getProgramLog NA

◆ reset()

void reset ( )

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

NA

◆ setUniformLocationWith1f()

void setUniformLocationWith1f ( GLint  location,
GLfloat  f1 
)

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

setUniformLocationF32 NA

◆ setUniformLocationWith1i()

void setUniformLocationWith1i ( GLint  location,
GLint  i1 
)

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

setUniformLocationI32 NA

◆ setUniformLocationWith2f()

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.

setUniformLocationF32 NA

◆ setUniformLocationWith2fv()

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.

NA NA

◆ setUniformLocationWith2i()

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.

NA

◆ setUniformLocationWith2iv()

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.

NA

◆ setUniformLocationWith3f()

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.

setUniformLocationF32 NA

◆ setUniformLocationWith3fv()

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.

NA NA

◆ setUniformLocationWith3i()

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.

NA

◆ setUniformLocationWith3iv()

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.

NA

◆ setUniformLocationWith4f()

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.

setUniformLocationF32 NA

◆ setUniformLocationWith4fv()

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.

NA NA

◆ setUniformLocationWith4i()

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.

NA

◆ setUniformLocationWith4iv()

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.

NA

◆ setUniformLocationWithMatrix4fv()

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.

NA NA

◆ setUniformsForBuiltins()

void setUniformsForBuiltins ( )

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

NA

◆ updateUniformLocation()

bool updateUniformLocation ( GLint  location,
GLvoid *  data,
unsigned int  bytes 
)
protected

◆ updateUniforms()

void updateUniforms ( )

It will create 4 uniforms:

  • kCCUniformPMatrix
  • kCCUniformMVMatrix
  • kCCUniformMVPMatrix
  • kCCUniformSampler

And it will bind "kCCUniformSampler" to 0 NA

◆ use()

void use ( )

it will call glUseProgram() NA

◆ vertexShaderLog()

const char * vertexShaderLog ( )

returns the vertexShader error log getVertexShaderLog NA

Member Data Documentation

◆ m_bUsesTime

bool m_bUsesTime
protected

◆ m_hasShaderCompiler

bool m_hasShaderCompiler
protected

◆ m_pHashForUniforms

struct _hashUniformEntry* m_pHashForUniforms
protected

◆ m_shaderId

std::string m_shaderId
protected

◆ m_uFragShader

GLuint m_uFragShader
protected

◆ m_uProgram

GLuint m_uProgram
protected

◆ m_uUniforms

GLint m_uUniforms[kCCUniform_MAX]
protected

◆ m_uVertShader

GLuint m_uVertShader
protected

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