Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
GLProgramState Class Reference

GLProgramState holds the 'state' (uniforms and attributes) of the GLProgram. More...

Inherits Ref.

Classes

class  AutoBindingResolver
 An abstract base class that can be extended to support custom material auto bindings. More...
 

Public Member Functions

GLProgramStateclone () const
 Returns a new copy of the GLProgramState. More...
 
local clone ()
 Returns a new copy of the GLProgramState. More...
 
void apply (const Mat4 &modelView)
 Apply GLProgram, attributes and uniforms. More...
 
var apply ( var modelView)
 Apply GLProgram, attributes and uniforms. More...
 
local apply ( local modelView)
 Apply GLProgram, attributes and uniforms. More...
 
void applyGLProgram (const Mat4 &modelView)
 Apply GLProgram, and built in uniforms. More...
 
local applyGLProgram ( local modelView)
 Apply GLProgram, and built in uniforms. More...
 
void applyAttributes (bool applyAttribFlags=true)
 Apply attributes. More...
 
local applyAttributes ( local true)
 Apply attributes. More...
 
void applyUniforms ()
 Apply user defined uniforms.
 
var applyUniforms ()
 Apply user defined uniforms.
 
local applyUniforms ()
 Apply user defined uniforms.
 
uint32_t getVertexAttribsFlags () const
 Get the flag of vertex attribs used by OR operation. More...
 
var getVertexAttribsFlags ()
 Get the flag of vertex attribs used by OR operation. More...
 
local getVertexAttribsFlags ()
 Get the flag of vertex attribs used by OR operation. More...
 
ssize_t getVertexAttribCount () const
 Get the number of vertex attributes. More...
 
ssize_t getUniformCount () const
 Get the number of user defined uniform count. More...
 
var getUniformCount ()
 Get the number of user defined uniform count. More...
 
local getUniformCount ()
 Get the number of user defined uniform count. More...
 
NodegetNodeBinding () const
 Returns the Node bound to the GLProgramState.
 
var getNodeBinding ()
 Returns the Node bound to the GLProgramState.
 
local getNodeBinding ()
 Returns the Node bound to the GLProgramState.
 
void setNodeBinding (Node *node)
 Sets the node that this render state is bound to. More...
 
local setNodeBinding ( local node)
 Sets the node that this render state is bound to. More...
 
void applyAutoBinding (const std::string &uniformName, const std::string &autoBinding)
 Applies the specified custom auto-binding. More...
 
var applyAutoBinding ( var uniformName, var autoBinding)
 Applies the specified custom auto-binding. More...
 
local applyAutoBinding ( local uniformName, local autoBinding)
 Applies the specified custom auto-binding. More...
 
void setParameterAutoBinding (const std::string &uniformName, const std::string &autoBinding)
 Sets a uniform auto-binding. More...
 
void setGLProgram (GLProgram *glprogram)
void setVertexAttribCallback (const std::string &name, const std::function< void(VertexAttrib *)> &callback)
void setUniformInt (const std::string &uniformName, int value)
var setUniformInt ( var uniformName, var value)
local setUniformInt ( local uniformName, local value)
void setUniformTexture (const std::string &uniformName, GLuint textureId)
var setUniformTexture ( var uniformName, var textureId)
local setUniformTexture ( local uniformName, local textureId)
void setUniformInt (GLint uniformLocation, int value)
void setUniformTexture (GLint uniformLocation, GLuint textureId)
var setUniformTexture ( var uniformLocation, var textureId)
local setUniformTexture ( local uniformLocation, local textureId)
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
local 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 ()
 Destructor. More...
 

Static Public Member Functions

static GLProgramStatecreate (GLProgram *glprogram)
 returns a new instance of GLProgramState for a given GLProgram
 
local create ( local glprogram)
 returns a new instance of GLProgramState for a given GLProgram
 
static GLProgramStategetOrCreateWithGLProgram (GLProgram *glprogram)
 gets-or-creates an instance of GLProgramState for a given GLProgram
 
var getOrCreateWithGLProgram ( var glprogram)
 gets-or-creates an instance of GLProgramState for a given GLProgram
 
local getOrCreateWithGLProgram ( local glprogram)
 gets-or-creates an instance of GLProgramState for a given GLProgram
 
static GLProgramStategetOrCreateWithGLProgramName (const std::string &glProgramName)
 gets-or-creates an instance of GLProgramState for a given GLProgramName
 
static GLProgramStategetOrCreateWithGLProgramName (const std::string &glProgramName, Texture2D *texture)
 gets-or-creates an instance of GLProgramState for the given GLProgramName & texture
 
local getOrCreateWithGLProgramName ( local glProgramName, local texture)
 gets-or-creates an instance of GLProgramState for the given GLProgramName & texture
 
static GLProgramStategetOrCreateWithShaders (const std::string &vertexShader, const std::string &fragShader, const std::string &compileTimeDefines)
 gets-or-creates an instance of GLProgramState for given shaders
 
local getOrCreateWithShaders ( local vertexShader, local fragShader, local compileTimeDefines)
 gets-or-creates an instance of GLProgramState for given shaders
 

Additional Inherited Members

- Public Attributes inherited from Ref
unsigned int _ID
 object id, ScriptSupport need public _ID
 
local _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
local _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
local _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 
local _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

GLProgramState holds the 'state' (uniforms and attributes) of the GLProgram.

A GLProgram can be used by thousands of Nodes, but if different uniform values are going to be used, then each node will need its own GLProgramState

Member Function Documentation

GLProgramState* clone ( ) const

Returns a new copy of the GLProgramState.

The GLProgram is reused

var clone ( )

Returns a new copy of the GLProgramState.

The GLProgram is reused

local clone ( )

Returns a new copy of the GLProgramState.

The GLProgram is reused

void apply ( const Mat4 modelView)

Apply GLProgram, attributes and uniforms.

Parameters
modelViewThe applied modelView matrix to shader.
var apply ( var  modelView)

Apply GLProgram, attributes and uniforms.

Parameters
modelViewThe applied modelView matrix to shader.
local apply ( local  modelView)

Apply GLProgram, attributes and uniforms.

Parameters
modelViewThe applied modelView matrix to shader.
void applyGLProgram ( const Mat4 modelView)

Apply GLProgram, and built in uniforms.

Parameters
modelViewThe applied modelView matrix to shader.
var applyGLProgram ( var  modelView)

Apply GLProgram, and built in uniforms.

Parameters
modelViewThe applied modelView matrix to shader.
local applyGLProgram ( local  modelView)

Apply GLProgram, and built in uniforms.

Parameters
modelViewThe applied modelView matrix to shader.
void applyAttributes ( bool  applyAttribFlags = true)

Apply attributes.

Parameters
applyAttribFlagsCall GL::enableVertexAttribs(_vertexAttribsFlags) or not.
var applyAttributes ( var  applyAttribFlags = true)

Apply attributes.

Parameters
applyAttribFlagsCall GL::enableVertexAttribs(_vertexAttribsFlags) or not.
local applyAttributes ( local  applyAttribFlags = true)

Apply attributes.

Parameters
applyAttribFlagsCall GL::enableVertexAttribs(_vertexAttribsFlags) or not.
void setGLProgram ( GLProgram glprogram)

Setter and Getter of the owner GLProgram binded in this program state.

var setGLProgram ( var  glprogram)

Setter and Getter of the owner GLProgram binded in this program state.

local setGLProgram ( local  glprogram)

Setter and Getter of the owner GLProgram binded in this program state.

uint32_t getVertexAttribsFlags ( ) const

Get the flag of vertex attribs used by OR operation.

var getVertexAttribsFlags ( )

Get the flag of vertex attribs used by OR operation.

local getVertexAttribsFlags ( )

Get the flag of vertex attribs used by OR operation.

ssize_t getVertexAttribCount ( ) const

Get the number of vertex attributes.

var getVertexAttribCount ( )

Get the number of vertex attributes.

local getVertexAttribCount ( )

Get the number of vertex attributes.

void setVertexAttribCallback ( const std::string &  name,
const std::function< void(VertexAttrib *)> &  callback 
)

Set the vertex attribute value.

var setVertexAttribCallback ( var  name,
var  callback 
)

Set the vertex attribute value.

local setVertexAttribCallback ( local  name,
local  callback 
)

Set the vertex attribute value.

ssize_t getUniformCount ( ) const
inline

Get the number of user defined uniform count.

var getUniformCount ( )
inline

Get the number of user defined uniform count.

local getUniformCount ( )
inline

Get the number of user defined uniform count.

void setUniformInt ( const std::string &  uniformName,
int  value 
)

Setting user defined uniforms by uniform string name in the shader.

var setUniformInt ( var  uniformName,
var  value 
)

Setting user defined uniforms by uniform string name in the shader.

local setUniformInt ( local  uniformName,
local  value 
)

Setting user defined uniforms by uniform string name in the shader.

void setUniformTexture ( const std::string &  uniformName,
GLuint  textureId 
)
var setUniformTexture ( var  uniformName,
var  textureId 
)
local setUniformTexture ( local  uniformName,
local  textureId 
)
void setUniformInt ( GLint  uniformLocation,
int  value 
)

Setting user defined uniforms by uniform location in the shader.

var setUniformInt ( var  uniformLocation,
var  value 
)

Setting user defined uniforms by uniform location in the shader.

local setUniformInt ( local  uniformLocation,
local  value 
)

Setting user defined uniforms by uniform location in the shader.

void setUniformTexture ( GLint  uniformLocation,
GLuint  textureId 
)
var setUniformTexture ( var  uniformLocation,
var  textureId 
)
local setUniformTexture ( local  uniformLocation,
local  textureId 
)
void setNodeBinding ( Node node)

Sets the node that this render state is bound to.

The specified node is used to apply auto-bindings for the render state. This is typically set to the node of the model that a material is applied to.

Parameters
nodeThe node to use for applying auto-bindings.
var setNodeBinding ( var  node)

Sets the node that this render state is bound to.

The specified node is used to apply auto-bindings for the render state. This is typically set to the node of the model that a material is applied to.

Parameters
nodeThe node to use for applying auto-bindings.
local setNodeBinding ( local  node)

Sets the node that this render state is bound to.

The specified node is used to apply auto-bindings for the render state. This is typically set to the node of the model that a material is applied to.

Parameters
nodeThe node to use for applying auto-bindings.
void applyAutoBinding ( const std::string &  uniformName,
const std::string &  autoBinding 
)

Applies the specified custom auto-binding.

Parameters
uniformNameName of the shader uniform.
autoBindingName of the auto binding.
var applyAutoBinding ( var  uniformName,
var  autoBinding 
)

Applies the specified custom auto-binding.

Parameters
uniformNameName of the shader uniform.
autoBindingName of the auto binding.
local applyAutoBinding ( local  uniformName,
local  autoBinding 
)

Applies the specified custom auto-binding.

Parameters
uniformNameName of the shader uniform.
autoBindingName of the auto binding.
void setParameterAutoBinding ( const std::string &  uniformName,
const std::string &  autoBinding 
)

Sets a uniform auto-binding.

This method parses the passed in autoBinding string and attempts to convert it to an enumeration value. If it matches to one of the predefined strings, it will create a callback to get the correct value at runtime.

Parameters
uniformNameThe name of the material parameter to store an auto-binding for.
autoBindingA string matching one of the built-in AutoBinding enum constants.
var setParameterAutoBinding ( var  uniformName,
var  autoBinding 
)

Sets a uniform auto-binding.

This method parses the passed in autoBinding string and attempts to convert it to an enumeration value. If it matches to one of the predefined strings, it will create a callback to get the correct value at runtime.

Parameters
uniformNameThe name of the material parameter to store an auto-binding for.
autoBindingA string matching one of the built-in AutoBinding enum constants.
local setParameterAutoBinding ( local  uniformName,
local  autoBinding 
)

Sets a uniform auto-binding.

This method parses the passed in autoBinding string and attempts to convert it to an enumeration value. If it matches to one of the predefined strings, it will create a callback to get the correct value at runtime.

Parameters
uniformNameThe name of the material parameter to store an auto-binding for.
autoBindingA string matching one of the built-in AutoBinding enum constants.

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