|
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 | |
| void | bind (const void *data) const |
| Sets the uniform data for the current shader program. | |
| bgfx::UniformHandle | handle () const |
| Returns the underlying 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) | |
| Creates a new shader uniform. | |
| Uniform (const Uniform &oth)=delete | |
| Uniform (Uniform &&oth) | |
| Move constructor. | |
| ~Uniform () | |
| Destructor. Destroys the underlying bgfx::UniformHandle. | |
Static Public Member Functions | |
| static uint | floatToUintBits (float f) |
| Utility function to reinterpret the bits of a float as an unsigned integer. | |
| static float | uintBitsToFloat (uint bits) |
| Utility function to reinterpret the bits of an unsigned integer as a float. | |
Private Attributes | |
| 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. |
|
inline |
Move constructor.
| [in] | oth | The Uniform to move from. |
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. |
Utility function to reinterpret the bits of a float as an unsigned integer.
| [in] | f | The float to convert. |
|
inline |
Returns the underlying bgfx::UniformHandle.
|
inline |
Returns the name of the uniform.
|
inline |
Returns the type of the uniform.
Utility function to reinterpret the bits of an unsigned integer as a float.
| [in] | bits | The unsigned integer to convert. |