|
Visual Computing Library
devel
|
The Uniform class wraps a bgfx::UniformHandle and provides a simple interface to set the uniform data. More...
#include <vclib/bgfx/uniform.h>
Public Member Functions | |
| uint16_t | arraySize () const |
| Returns the array size of the uniform (number of elements for array uniforms, 1 for non-array uniforms). | |
| void | bind (const void *data) const |
| Sets the uniform data for the current shader program. | |
| void | bind (const void *data, uint16_t numElements) const |
| Sets the uniform data for the current shader program, specifying the number of elements for array uniforms. | |
| bgfx::UniformHandle | handle () const |
| Returns the underlying bgfx::UniformHandle. | |
| bool | isValid () const |
| Checks if the Uniform is valid (i.e., if it has a valid bgfx::UniformHandle). | |
| const std::string & | name () const |
| Returns the name of the uniform. | |
| Uniform & | operator= (const Uniform &oth)=delete |
| Uniform & | operator= (Uniform &&oth) |
| Move assignment operator. | |
| void | swap (Uniform &oth) |
| Swaps the content of this Uniform with another. | |
| bgfx::UniformType::Enum | type () const |
| Returns the type of the uniform. | |
| Uniform ()=default | |
| Default constructor. Creates an invalid Uniform. | |
| Uniform (const std::string &name, bgfx::UniformType::Enum type, uint16_t size=1) | |
| Creates a new shader uniform. | |
| Uniform (const Uniform &oth)=delete | |
| Uniform (Uniform &&oth) | |
| Move constructor. | |
| ~Uniform () | |
| Destructor. Destroys the underlying bgfx::UniformHandle. | |
Private Attributes | |
| uint16_t | mArraySize = 1 |
| bgfx::UniformHandle | mUniformHandle = BGFX_INVALID_HANDLE |
| std::string | mUniformName |
| bgfx::UniformType::Enum | mUniformType = bgfx::UniformType::Count |
Friends | |
| void | swap (Uniform &a, Uniform &b) |
| Swaps two Uniform objects. | |
The Uniform class wraps a bgfx::UniformHandle and provides a simple interface to set the uniform data.
It manages the lifetime of the bgfx::UniformHandle: each instance of this class creates a new bgfx::UniformHandle and destroys it when the instance goes out of scope. This simplifies resource management for shader uniforms.
|
inline |
Creates a new shader uniform.
| [in] | name | The name of the uniform. It must match the name used in the shader. |
| [in] | type | The data type of the uniform. |
| [in] | size | The number of elements for array uniforms (default is 1 for non-array uniforms). |
|
inline |
Move constructor.
| [in] | oth | The Uniform to move from. |
|
inline |
Returns the array size of the uniform (number of elements for array uniforms, 1 for non-array uniforms).
Sets the uniform data for the current shader program.
This function should be called after a shader program has been set with bgfx::submit(). The data pointer must point to a memory block that matches the uniform's type and size.
| [in] | data | A pointer to the uniform data. |
Sets the uniform data for the current shader program, specifying the number of elements for array uniforms.
This function should be called after a shader program has been set with bgfx::submit(). The data pointer must point to a memory block that matches the uniform's type and size. The numElements parameter specifies how many elements of the array uniform to set (for non-array uniforms, this should be 1).
| [in] | data | A pointer to the uniform data. |
| [in] | numElements | The number of elements to set for array uniforms. |
|
inline |
Returns the underlying bgfx::UniformHandle.
|
inline |
|
inline |
Returns the name of the uniform.
|
inline |
Returns the type of the uniform.