cocos2d-x  2.2.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Shaders

Files

file  ccGLStateCache.h
 

Classes

class  CCGLProgram
 CCGLProgram Class that implements a glProgram. More...
 
class  CCShaderCache
 CCShaderCache Singleton that stores manages GL shaders. More...
 

Macros

#define kCCShader_PositionTextureColor   "ShaderPositionTextureColor"
#define kCCShader_PositionTextureColorAlphaTest   "ShaderPositionTextureColorAlphaTest"
#define kCCShader_PositionColor   "ShaderPositionColor"
#define kCCShader_PositionTexture   "ShaderPositionTexture"
#define kCCShader_PositionTexture_uColor   "ShaderPositionTexture_uColor"
#define kCCShader_PositionTextureA8Color   "ShaderPositionTextureA8Color"
#define kCCShader_Position_uColor   "ShaderPosition_uColor"
#define kCCShader_PositionLengthTexureColor   "ShaderPositionLengthTextureColor"
#define kCCShader_ControlSwitch   "Shader_ControlSwitch"
#define kCCUniformPMatrix_s   "CC_PMatrix"
#define kCCUniformMVMatrix_s   "CC_MVMatrix"
#define kCCUniformMVPMatrix_s   "CC_MVPMatrix"
#define kCCUniformTime_s   "CC_Time"
#define kCCUniformSinTime_s   "CC_SinTime"
#define kCCUniformCosTime_s   "CC_CosTime"
#define kCCUniformRandom01_s   "CC_Random01"
#define kCCUniformSampler_s   "CC_Texture0"
#define kCCUniformAlphaTestValue   "CC_alpha_value"
#define kCCAttributeNameColor   "a_color"
#define kCCAttributeNamePosition   "a_position"
#define kCCAttributeNameTexCoord   "a_texCoord"

Typedefs

typedef void(* GLInfoFunction )(GLuint program, GLenum pname, GLint *params)
typedef void(* GLLogFunction )(GLuint program, GLsizei bufsize, GLsizei *length, GLchar *infolog)

Enumerations

enum  { kCCVertexAttrib_Position, kCCVertexAttrib_Color, kCCVertexAttrib_TexCoords, kCCVertexAttrib_MAX }
 
enum  {
  kCCUniformPMatrix, kCCUniformMVMatrix, kCCUniformMVPMatrix, kCCUniformTime,
  kCCUniformSinTime, kCCUniformCosTime, kCCUniformRandom01, kCCUniformSampler,
  kCCUniform_MAX
}
 
enum  {
  kCCVertexAttribFlag_None = 0, kCCVertexAttribFlag_Position = 1 << 0, kCCVertexAttribFlag_Color = 1 << 1, kCCVertexAttribFlag_TexCoords = 1 << 2,
  kCCVertexAttribFlag_PosColorTex = ( kCCVertexAttribFlag_Position | kCCVertexAttribFlag_Color | kCCVertexAttribFlag_TexCoords )
}
 vertex attrib flags More...
 
enum  ccGLServerState { CC_GL_ALL = 0 }
 GL server side states. More...
 

Functions

void CC_DLL  (void)
 Invalidates the GL state cache. More...
 
void CC_DLL  (GLuint program)
 Uses the GL program in case program is different than the current one. More...
 
void CC_DLL  (GLenum sfactor, GLenum dfactor)
 Uses a blending function in case it not already used. More...
 
void CC_DLL  (unsigned int flags)
 Will enable the vertex attribs that are passed as flags. More...
 
void CC_DLL  (GLuint textureUnit, GLuint textureId)
 If the texture is not already bound to a given unit, it binds it. More...
 
void CC_DLL  (ccGLServerState flags)
 It will enable / disable the server side GL states. More...
 

Variables

CC_DLL const GLcharccPosition_uColor_frag
CC_DLL const GLcharccPosition_uColor_vert
var ccPosition_uColor_vert
local ccPosition_uColor_vert
CC_DLL const GLcharccPositionColor_frag
var ccPositionColor_frag
local ccPositionColor_frag
CC_DLL const GLcharccPositionColor_vert
var ccPositionColor_vert
local ccPositionColor_vert
CC_DLL const GLcharccPositionTexture_frag
var ccPositionTexture_frag
local ccPositionTexture_frag
CC_DLL const GLcharccPositionTexture_vert
var ccPositionTexture_vert
local ccPositionTexture_vert
CC_DLL const GLcharccPositionTextureA8Color_frag
CC_DLL const GLcharccPositionTextureA8Color_vert
var ccPositionTextureA8Color_vert
local ccPositionTextureA8Color_vert
CC_DLL const GLcharccPositionTextureColor_frag
var ccPositionTextureColor_frag
local ccPositionTextureColor_frag
CC_DLL const GLcharccPositionTextureColor_vert
var ccPositionTextureColor_vert
local ccPositionTextureColor_vert
CC_DLL const GLcharccPositionTextureColorAlphaTest_frag
CC_DLL const GLcharccPositionTexture_uColor_frag
var ccPositionTexture_uColor_frag
local ccPositionTexture_uColor_frag
CC_DLL const GLcharccPositionTexture_uColor_vert
var ccPositionTexture_uColor_vert
local ccPositionTexture_uColor_vert
CC_DLL const GLcharccPositionColorLengthTexture_frag
CC_DLL const GLcharccPositionColorLengthTexture_vert
var ccPositionColorLengthTexture_vert
local ccPositionColorLengthTexture_vert
CC_DLL const GLcharccExSwitchMask_frag
var ccExSwitchMask_frag
local ccExSwitchMask_frag

Detailed Description

Macro Definition Documentation

#define kCCAttributeNameColor   "a_color"
var kCCAttributeNameColor   "a_color"
local kCCAttributeNameColor   "a_color"
#define kCCAttributeNamePosition   "a_position"
var kCCAttributeNamePosition   "a_position"
local kCCAttributeNamePosition   "a_position"
#define kCCAttributeNameTexCoord   "a_texCoord"
var kCCAttributeNameTexCoord   "a_texCoord"
local kCCAttributeNameTexCoord   "a_texCoord"
#define kCCShader_ControlSwitch   "Shader_ControlSwitch"
var kCCShader_ControlSwitch   "Shader_ControlSwitch"
local kCCShader_ControlSwitch   "Shader_ControlSwitch"
#define kCCShader_Position_uColor   "ShaderPosition_uColor"
var kCCShader_Position_uColor   "ShaderPosition_uColor"
local kCCShader_Position_uColor   "ShaderPosition_uColor"
#define kCCShader_PositionColor   "ShaderPositionColor"
var kCCShader_PositionColor   "ShaderPositionColor"
local kCCShader_PositionColor   "ShaderPositionColor"
#define
kCCShader_PositionLengthTexureColor   "ShaderPositionLengthTextureColor"
var
kCCShader_PositionLengthTexureColor   "ShaderPositionLengthTextureColor"
local
kCCShader_PositionLengthTexureColor   "ShaderPositionLengthTextureColor"
#define kCCShader_PositionTexture   "ShaderPositionTexture"
var kCCShader_PositionTexture   "ShaderPositionTexture"
local kCCShader_PositionTexture   "ShaderPositionTexture"
#define
kCCShader_PositionTexture_uColor   "ShaderPositionTexture_uColor"
var
kCCShader_PositionTexture_uColor   "ShaderPositionTexture_uColor"
local
kCCShader_PositionTexture_uColor   "ShaderPositionTexture_uColor"
#define
kCCShader_PositionTextureA8Color   "ShaderPositionTextureA8Color"
var
kCCShader_PositionTextureA8Color   "ShaderPositionTextureA8Color"
local
kCCShader_PositionTextureA8Color   "ShaderPositionTextureA8Color"
#define
kCCShader_PositionTextureColor   "ShaderPositionTextureColor"
var kCCShader_PositionTextureColor   "ShaderPositionTextureColor"
#define
kCCShader_PositionTextureColorAlphaTest   "ShaderPositionTextureColorAlphaTest"
var
kCCShader_PositionTextureColorAlphaTest   "ShaderPositionTextureColorAlphaTest"
local
kCCShader_PositionTextureColorAlphaTest   "ShaderPositionTextureColorAlphaTest"
#define kCCUniformAlphaTestValue   "CC_alpha_value"
var kCCUniformAlphaTestValue   "CC_alpha_value"
local kCCUniformAlphaTestValue   "CC_alpha_value"
#define kCCUniformCosTime_s   "CC_CosTime"
var kCCUniformCosTime_s   "CC_CosTime"
local kCCUniformCosTime_s   "CC_CosTime"
#define kCCUniformMVMatrix_s   "CC_MVMatrix"
var kCCUniformMVMatrix_s   "CC_MVMatrix"
local kCCUniformMVMatrix_s   "CC_MVMatrix"
#define kCCUniformMVPMatrix_s   "CC_MVPMatrix"
var kCCUniformMVPMatrix_s   "CC_MVPMatrix"
local kCCUniformMVPMatrix_s   "CC_MVPMatrix"
#define kCCUniformPMatrix_s   "CC_PMatrix"
var kCCUniformPMatrix_s   "CC_PMatrix"
local kCCUniformPMatrix_s   "CC_PMatrix"
#define kCCUniformRandom01_s   "CC_Random01"
var kCCUniformRandom01_s   "CC_Random01"
local kCCUniformRandom01_s   "CC_Random01"
#define kCCUniformSampler_s   "CC_Texture0"
var kCCUniformSampler_s   "CC_Texture0"
local kCCUniformSampler_s   "CC_Texture0"
#define kCCUniformSinTime_s   "CC_SinTime"
var kCCUniformSinTime_s   "CC_SinTime"
local kCCUniformSinTime_s   "CC_SinTime"
#define kCCUniformTime_s   "CC_Time"
var kCCUniformTime_s   "CC_Time"
local kCCUniformTime_s   "CC_Time"

Typedef Documentation

typedef void(* GLInfoFunction)(GLuint
program, GLenum pname, GLint
*params)
typedef void(* GLInfoFunction)(GLuint
program, GLenum pname, GLint
*params)
typedef void(* GLInfoFunction)(GLuint
program, GLenum pname, GLint
*params)
typedef void(* GLLogFunction)(GLuint
program, GLsizei bufsize,
GLsizei *length, GLchar
*infolog)
typedef void(* GLLogFunction)(GLuint
program, GLsizei bufsize,
GLsizei *length, GLchar
*infolog)
typedef void(* GLLogFunction)(GLuint
program, GLsizei bufsize,
GLsizei *length, GLchar
*infolog)

Enumeration Type Documentation

anonymous enum
Enumerator
kCCVertexAttrib_Position 
kCCVertexAttrib_Color 
kCCVertexAttrib_TexCoords 
kCCVertexAttrib_MAX 
var enum
Enumerator
kCCVertexAttrib_Position 
kCCVertexAttrib_Color 
kCCVertexAttrib_TexCoords 
kCCVertexAttrib_MAX 
local enum
Enumerator
kCCVertexAttrib_Position 
kCCVertexAttrib_Color 
kCCVertexAttrib_TexCoords 
kCCVertexAttrib_MAX 
anonymous enum
Enumerator
kCCUniformPMatrix 
kCCUniformMVMatrix 
kCCUniformMVPMatrix 
kCCUniformTime 
kCCUniformSinTime 
kCCUniformCosTime 
kCCUniformRandom01 
kCCUniformSampler 
kCCUniform_MAX 
var enum
Enumerator
kCCUniformPMatrix 
kCCUniformMVMatrix 
kCCUniformMVPMatrix 
kCCUniformTime 
kCCUniformSinTime 
kCCUniformCosTime 
kCCUniformRandom01 
kCCUniformSampler 
kCCUniform_MAX 
local enum
Enumerator
kCCUniformPMatrix 
kCCUniformMVMatrix 
kCCUniformMVPMatrix 
kCCUniformTime 
kCCUniformSinTime 
kCCUniformCosTime 
kCCUniformRandom01 
kCCUniformSampler 
kCCUniform_MAX 
anonymous enum

vertex attrib flags

Enumerator
kCCVertexAttribFlag_None 
kCCVertexAttribFlag_Position 
kCCVertexAttribFlag_Color 
kCCVertexAttribFlag_TexCoords 
kCCVertexAttribFlag_PosColorTex 
var enum

vertex attrib flags

Enumerator
kCCVertexAttribFlag_None 
kCCVertexAttribFlag_Position 
kCCVertexAttribFlag_Color 
kCCVertexAttribFlag_TexCoords 
kCCVertexAttribFlag_PosColorTex 
local enum

vertex attrib flags

Enumerator
kCCVertexAttribFlag_None 
kCCVertexAttribFlag_Position 
kCCVertexAttribFlag_Color 
kCCVertexAttribFlag_TexCoords 
kCCVertexAttribFlag_PosColorTex 
enum ccGLServerState

GL server side states.

Enumerator
CC_GL_ALL 
var ccGLServerState

GL server side states.

Enumerator
CC_GL_ALL 
local ccGLServerState

GL server side states.

Enumerator
CC_GL_ALL 

Function Documentation

void CC_DLL
cocos2d::ccGLInvalidateStateCache
( void  )

Invalidates the GL state cache.

If CC_ENABLE_GL_STATE_CACHE it will reset the GL state cache.

Since
v2.0.0
var ccGLInvalidateStateCache (   )

Invalidates the GL state cache.

If CC_ENABLE_GL_STATE_CACHE it will reset the GL state cache.

Since
v2.0.0
local ccGLInvalidateStateCache (   )

Invalidates the GL state cache.

If CC_ENABLE_GL_STATE_CACHE it will reset the GL state cache.

Since
v2.0.0
void CC_DLL cocos2d::ccGLUseProgram ( GLuint  program)

Uses the GL program in case program is different than the current one.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly.

Since
v2.0.0
var ccGLUseProgram ( var  program)

Uses the GL program in case program is different than the current one.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly.

Since
v2.0.0
local ccGLUseProgram ( local  program)

Uses the GL program in case program is different than the current one.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glUseProgram() directly.

Since
v2.0.0
void CC_DLL cocos2d::ccGLBlendFunc ( GLenum  sfactor,
GLenum  dfactor 
)

Uses a blending function in case it not already used.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly.

Since
v2.0.0
var ccGLBlendFunc ( var  sfactor,
var  dfactor 
)

Uses a blending function in case it not already used.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly.

Since
v2.0.0
local ccGLBlendFunc ( local  sfactor,
local  dfactor 
)

Uses a blending function in case it not already used.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will the glBlendFunc() directly.

Since
v2.0.0
void CC_DLL
cocos2d::ccGLEnableVertexAttribs
( unsigned int  flags)

Will enable the vertex attribs that are passed as flags.

Possible flags:

 kCCVertexAttribFlag_Position
 kCCVertexAttribFlag_Color
 kCCVertexAttribFlag_TexCoords

These flags can be ORed. The flags that are not present, will be disabled.

Since
v2.0.0
var ccGLEnableVertexAttribs ( var  flags)

Will enable the vertex attribs that are passed as flags.

Possible flags:

 kCCVertexAttribFlag_Position
 kCCVertexAttribFlag_Color
 kCCVertexAttribFlag_TexCoords

These flags can be ORed. The flags that are not present, will be disabled.

Since
v2.0.0
local ccGLEnableVertexAttribs ( local  flags)

Will enable the vertex attribs that are passed as flags.

Possible flags:

 kCCVertexAttribFlag_Position
 kCCVertexAttribFlag_Color
 kCCVertexAttribFlag_TexCoords

These flags can be ORed. The flags that are not present, will be disabled.

Since
v2.0.0
void CC_DLL
cocos2d::ccGLBindTexture2DN
( GLuint  textureUnit,
GLuint  textureId 
)

If the texture is not already bound to a given unit, it binds it.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly.

Since
v2.1.0
var ccGLBindTexture2DN ( var  textureUnit,
var  textureId 
)

If the texture is not already bound to a given unit, it binds it.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly.

Since
v2.1.0
local ccGLBindTexture2DN ( local  textureUnit,
local  textureId 
)

If the texture is not already bound to a given unit, it binds it.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glBindTexture() directly.

Since
v2.1.0
void CC_DLL cocos2d::ccGLEnable ( ccGLServerState  flags)

It will enable / disable the server side GL states.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glEnable() directly.

Since
v2.0.0
var ccGLEnable ( var  flags)

It will enable / disable the server side GL states.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glEnable() directly.

Since
v2.0.0
local ccGLEnable ( local  flags)

It will enable / disable the server side GL states.

If CC_ENABLE_GL_STATE_CACHE is disabled, it will call glEnable() directly.

Since
v2.0.0

Variable Documentation

CC_DLL const GLchar*
ccExSwitchMask_frag
var ccExSwitchMask_frag
local ccExSwitchMask_frag
CC_DLL const GLchar*
ccPosition_uColor_frag
var ccPosition_uColor_frag
local ccPosition_uColor_frag
CC_DLL const GLchar*
ccPosition_uColor_vert
var ccPosition_uColor_vert
local ccPosition_uColor_vert
CC_DLL const GLchar*
ccPositionColor_frag
var ccPositionColor_frag
local ccPositionColor_frag
CC_DLL const GLchar*
ccPositionColor_vert
var ccPositionColor_vert
local ccPositionColor_vert
CC_DLL const GLchar*
ccPositionColorLengthTexture_frag
var
ccPositionColorLengthTexture_frag
local
ccPositionColorLengthTexture_frag
CC_DLL const GLchar*
ccPositionColorLengthTexture_vert
var
ccPositionColorLengthTexture_vert
local
ccPositionColorLengthTexture_vert
CC_DLL const GLchar*
ccPositionTexture_frag
var ccPositionTexture_frag
local ccPositionTexture_frag
CC_DLL const GLchar*
ccPositionTexture_uColor_frag
var ccPositionTexture_uColor_frag
local ccPositionTexture_uColor_frag
CC_DLL const GLchar*
ccPositionTexture_uColor_vert
var ccPositionTexture_uColor_vert
local ccPositionTexture_uColor_vert
CC_DLL const GLchar*
ccPositionTexture_vert
var ccPositionTexture_vert
local ccPositionTexture_vert
CC_DLL const GLchar*
ccPositionTextureA8Color_frag
var ccPositionTextureA8Color_frag
local ccPositionTextureA8Color_frag
CC_DLL const GLchar*
ccPositionTextureA8Color_vert
var ccPositionTextureA8Color_vert
local ccPositionTextureA8Color_vert
CC_DLL const GLchar*
ccPositionTextureColor_frag
var ccPositionTextureColor_frag
local ccPositionTextureColor_frag
CC_DLL const GLchar*
ccPositionTextureColor_vert
var ccPositionTextureColor_vert
local ccPositionTextureColor_vert
CC_DLL const GLchar*
ccPositionTextureColorAlphaTest_frag
var
ccPositionTextureColorAlphaTest_frag
local
ccPositionTextureColorAlphaTest_frag