Cocos2d-x  4.0.0
Classes | Public Member Functions | List of all members
ProgramState Class Reference

A program state object can create or reuse a program. More...

Inherits Ref.

Classes

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

Public Member Functions

 ProgramState (Program *program)
 
virtual ~ProgramState ()
 destructor
 
ProgramStateclone () const
 Deep clone ProgramState.
 
backend::Program * getProgram () const
 Get the program object.
 
void setUniform (const backend::UniformLocation &uniformLocation, const void *data, std::size_t size)
 Specify the value of a uniform variable for the current program state object.
 
backend::UniformLocation getUniformLocation (const std::string &uniform) const
 Get uniform location in given uniform name.
 
backend::UniformLocation getUniformLocation (backend::Uniform name) const
 Get uniform location in a more efficient way by the given built-in uniform name.
 
int getAttributeLocation (const std::string &name) const
 Get an attribute location by the actual attribute name.
 
int getAttributeLocation (Attribute name) const
 Get an attribute location by the engine built-in attribute name.
 
void setCallbackUniform (const backend::UniformLocation &, const UniformCallback &)
 A callback to update unifrom.
 
void setTexture (const backend::UniformLocation &uniformLocation, uint32_t slot, backend::TextureBackend *texture)
 Set texture.
 
void setTextureArray (const backend::UniformLocation &uniformLocation, const std::vector< uint32_t > &slots, const std::vector< backend::TextureBackend * > textures)
 Set textures in array.
 
const std::unordered_map< int,
TextureInfo > & 
getVertexTextureInfos () const
 Get vertex texture informations.
 
const std::unordered_map< int,
TextureInfo > & 
getFragmentTextureInfos () const
 Get fragment texture informations.
 
const std::unordered_map
< UniformLocation,
UniformCallback,
UniformLocation > & 
getCallbackUniforms () const
 Get the uniform callback function.
 
void getVertexUniformBuffer (char **buffer, std::size_t &size) const
 Get vertex uniform buffer.
 
void getFragmentUniformBuffer (char **buffer, std::size_t &size) const
 Get fragment uniform buffer.
 
void setParameterAutoBinding (const std::string &uniformName, const std::string &autoBinding)
 Sets a uniform auto-binding.
 

Detailed Description

A program state object can create or reuse a program.

Each program state object keep its own unifroms and textures data.

Constructor & Destructor Documentation

ProgramState ( Program *  program)
Parameters
programSpecifies the program.

Member Function Documentation

void setUniform ( const backend::UniformLocation &  uniformLocation,
const void *  data,
std::size_t  size 
)

Specify the value of a uniform variable for the current program state object.

Parameters
uniformLocationSpecifies the uniform location.
dataSpecifies the new values to be used for the specified uniform variable.
sizeSpecifies the uniform data size.
backend::UniformLocation getUniformLocation ( const std::string &  uniform) const

Get uniform location in given uniform name.

Parameters
uniformSpecifies the uniform name.
Returns
Uniform location.
See Also
backend::UniformLocation getUniformLocation(backend::Uniform name) const
backend::UniformLocation getUniformLocation ( backend::Uniform  name) const

Get uniform location in a more efficient way by the given built-in uniform name.

Parameters
uniformSpecifies the engin built-in uniform name.
Returns
Uniform location.
See Also
backend::UniformLocation getUniformLocation(backend::Uniform name) const
int getAttributeLocation ( const std::string &  name) const
inline

Get an attribute location by the actual attribute name.

Parameters
nameSpecifies the attribute name.
Returns
Attribute location.
See Also
int getAttributeLocation(const std::string& name) const
int getAttributeLocation ( Attribute  name) const
inline

Get an attribute location by the engine built-in attribute name.

Parameters
nameSpecifies the built-in attribute name.
Returns
Attribute location.
See Also
int getAttributeLocation(const std::string& name) const
void setCallbackUniform ( const backend::UniformLocation &  ,
const UniformCallback &   
)

A callback to update unifrom.

Parameters
uniformLocationSpecifies the uniform location.
unifromCallbackSpecifies a callback function to update the uniform.
void setTexture ( const backend::UniformLocation &  uniformLocation,
uint32_t  slot,
backend::TextureBackend *  texture 
)

Set texture.

Parameters
uniformLocationSpecifies texture location.
slotSpecifies texture slot selector.
textureSpecifies a pointer to backend texture.
void setTextureArray ( const backend::UniformLocation &  uniformLocation,
const std::vector< uint32_t > &  slots,
const std::vector< backend::TextureBackend * >  textures 
)

Set textures in array.

Parameters
uniformLocationSpecifies texture location.
slotsSpecifies texture slot selector.
texturesSpecifies a vector of backend texture object.
const std::unordered_map<int, TextureInfo>& getVertexTextureInfos ( ) const
inline

Get vertex texture informations.

Returns
Vertex texture informations. Key is the texture location, Value store the texture informations
const std::unordered_map<int, TextureInfo>& getFragmentTextureInfos ( ) const
inline

Get fragment texture informations.

Returns
Fragment texture informations. Key is the texture location, Value store the texture informations
const std::unordered_map<UniformLocation, UniformCallback, UniformLocation>& getCallbackUniforms ( ) const
inline

Get the uniform callback function.

Returns
Uniform callback funciton.
void getVertexUniformBuffer ( char **  buffer,
std::size_t &  size 
) const

Get vertex uniform buffer.

The buffer store all the vertex uniform's data.

Parameters
[out]bufferSpecifies the pointer points to a vertex uniform storage.
[out]sizeSpecifies the size of the buffer in bytes.
void getFragmentUniformBuffer ( char **  buffer,
std::size_t &  size 
) const

Get fragment uniform buffer.

The buffer store all the fragment uniform's data for metal.

Parameters
[out]bufferSpecifies the pointer points to a fragment uniform storage.
[out]sizeSpecifies the size of the buffer in bytes.
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.

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