⚠️ This documentation corresponds to the latest development branch of axmol. It might diverge from the official releases.

Axmol Engine 3.0.0-84160d4
Loading...
Searching...
No Matches
ProgramState Class Reference

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

#include <ProgramState.h>

Inherits Object.

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
 Creates a deep copy of the current ProgramState.
rhi::ProgramgetProgram () const
 Get the program object.
void setUniform (const rhi::UniformLocation &uniformLocation, const void *data, std::size_t size)
 Specify the value of a uniform variable for the current program state object.
rhi::UniformLocation getUniformLocation (std::string_view uniform) const
 Get uniform location in given uniform name.
rhi::UniformLocation getUniformLocation (rhi::Uniform name) const
 Get uniform location in a more efficient way by the given built-in uniform name.
const VertexInputDesc * getVertexInputDesc (std::string_view name) const
 Get an attribute location by the actual attribute name.
const VertexInputDesc * getVertexInputDesc (VertexInputKind name) const
 Get an attribute location by the engine built-in attribute name.
void setCallbackUniform (const rhi::UniformLocation &, const UniformCallback &)
 A callback to update unifrom.
const std::unordered_map< UniformLocation, UniformCallback, UniformLocation > & getCallbackUniforms () const
 Get the uniform callback function.
void setTexture (rhi::Texture *texture)
 Set texture.
void setTextureArray (const rhi::UniformLocation &uniformLocation, std::span< TextureBinding > units)
 Set texture array in shader 'uniform sampler2D xxx[4];' unlikely sampoler2DArray, the array will use multi texture units.
const std::unordered_map< int, TextureBindingSet > & getTextureBindingSets () const
 Get vertex texture informations.
void setParameterAutoBinding (std::string_view uniformName, std::string_view autoBinding)
 Sets a uniform auto-binding.
Public Member Functions inherited from Object
void retain ()
 Retains the ownership.
void release ()
 Releases the ownership immediately.
Objectautorelease ()
 Releases the ownership sometime soon automatically.
unsigned int getReferenceCount () const
 Returns the Object's current reference count.
virtual ~Object ()
 Destructor.

Additional Inherited Members

Public Attributes inherited from Object
unsigned int _ID
 object id, ScriptSupport need public _ID
int _luaID
 Lua reference id.

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()

ProgramState ( Program * program)
Parameters
programSpecifies the program.

Member Function Documentation

◆ clone()

ProgramState * clone ( ) const

Creates a deep copy of the current ProgramState.

Unlike other clone methods, this function does not use autorelease. The returned object is allocated on the heap, and the caller is responsible for managing its lifetime and explicitly releasing it when no longer needed.

◆ setUniform()

void setUniform ( const rhi::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.

◆ getUniformLocation() [1/2]

rhi::UniformLocation getUniformLocation ( std::string_view uniform) const

Get uniform location in given uniform name.

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

◆ getUniformLocation() [2/2]

rhi::UniformLocation getUniformLocation ( rhi::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
rhi::UniformLocation getUniformLocation(rhi::Uniform name) const

◆ getVertexInputDesc() [1/2]

const VertexInputDesc * getVertexInputDesc ( std::string_view name) const
inline

Get an attribute location by the actual attribute name.

Parameters
nameSpecifies the attribute name.
Returns
Attribute location.
See also
int getAttributeLocation(std::string_view name) const

◆ getVertexInputDesc() [2/2]

const VertexInputDesc * getVertexInputDesc ( VertexInputKind 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(std::string_view name) const

◆ setCallbackUniform()

void setCallbackUniform ( const rhi::UniformLocation & ,
const UniformCallback &  )

A callback to update unifrom.

Parameters
uniformLocationSpecifies the uniform location.
unifromCallbackSpecifies a callback function to update the uniform.

◆ getCallbackUniforms()

const std::unordered_map< UniformLocation, UniformCallback, UniformLocation > & getCallbackUniforms ( ) const
inline

Get the uniform callback function.

Returns
Uniform callback funciton.

◆ setTexture()

void setTexture ( rhi::Texture * texture)

Set texture.

Parameters
uniformLocationSpecifies texture location.
textureSpecifies a pointer to backend texture.

◆ getTextureBindingSets()

const std::unordered_map< int, TextureBindingSet > & getTextureBindingSets ( ) const
inline

Get vertex texture informations.

Returns
Vertex texture informations. Key is the texture location, Value store the texture informations

◆ setParameterAutoBinding()

void setParameterAutoBinding ( std::string_view uniformName,
std::string_view 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:
  • ProgramState.h