UniformValueMap Class
Maps uniform semantics to their values for shader parameter binding. More...
Declaration
Public Constructors Index
| UniformValueMap ()=default | |
|
Default constructor. More... | |
Public Destructor Index
| ~UniformValueMap ()=default | |
|
Default destructor. More... | |
Public Member Functions Index
| void | set (UniformSemantics uniformSemantics, const helios::math::mat4f &mat4f) noexcept |
|
Sets or updates a `helios::math::mat4f` uniform value for a given semantic. More... | |
| void | set (UniformSemantics uniformSemantics, const helios::math::vec4f &vec4f) noexcept |
|
Sets or updates a `helios::math::vec4f` uniform value for a given semantic. More... | |
| void | set (UniformSemantics uniformSemantics, int value) noexcept |
|
Sets or updates an integer uniform value for a given semantic. More... | |
| void | set (UniformSemantics uniformSemantics, float value) noexcept |
|
Sets or updates a float uniform value for a given semantic. More... | |
| const float * | mat4f_ptr (UniformSemantics uniformSemantics) const noexcept |
|
Returns a raw const pointer to the `mat4f` for the specified uniform semantics. More... | |
| const helios::math::mat4f * | mat4f (UniformSemantics uniformSemantics) const noexcept |
|
Returns a const pointer to the `mat4f` value for the specified uniform semantics. More... | |
| const float * | vec4f_ptr (UniformSemantics uniformSemantics) const noexcept |
|
Returns a raw const pointer to the `vec4f` for the specified uniform semantics. More... | |
| const float * | float_ptr (UniformSemantics uniformSemantics) const noexcept |
|
Returns a raw const pointer to the float value for the specified uniform semantics. More... | |
| const int * | int_ptr (UniformSemantics uniformSemantics) const noexcept |
|
Returns a raw const pointer to the integer value for the specified uniform semantics. More... | |
Private Member Attributes Index
| std::array< std::optional< UniformValue >, std::to_underlying(UniformSemantics::size_)> | map_ |
|
Internal data structure storing the association between a uniform semantic and a concrete value. More... | |
Description
Maps uniform semantics to their values for shader parameter binding.
`UniformValueMap` stores uniform values (matrices, vectors, scalars) indexed by their `UniformSemantics` identifier. This allows the rendering pipeline to efficiently pass data to shaders without string-based lookups.
## Supported Types
- `mat4f` – 4x4 transformation matrices
- `vec4f` – 4-component vectors (colors, positions)
- `float` – Scalar values (roughness, time)
- `int` – Integer values (texture units)
## Usage
```cpp UniformValueMap uniforms;
// Set transform matrices uniforms.set(UniformSemantics::ModelMatrix, modelMat); uniforms.set(UniformSemantics::ViewMatrix, viewMat);
// Set material properties uniforms.set(UniformSemantics::MaterialBaseColor, vec4f{1.0f, 0.0f, 0.0f, 1.0f});
// Retrieve raw pointer for OpenGL const float* modelPtr = uniforms.mat4f_ptr(UniformSemantics::ModelMatrix); ```
- Todo
-
UniformMap must allow only one index for all data structures, i.e. if map_[semantics] contains a mat4f, other types should not be allowed for the same semantics.
- Todo
-
UniformValueMaps should be scoped, e.g. per frame (world matrix, projection, view...), per material (colors, emissive...), per object (world matrix...), which allows for better handling of assigning uniforms: per-frame values change once per frame, while per-object values change per object.
Definition at line 71 of file UniformValueMap.ixx.
Public Constructors
UniformValueMap()
| default |
Default constructor.
Initializes an empty uniform value map with no values set.
Definition at line 92 of file UniformValueMap.ixx.
Public Destructor
~UniformValueMap()
| default |
Default destructor.
Definition at line 85 of file UniformValueMap.ixx.
Public Member Functions
float_ptr()
| inline nodiscard noexcept |
Returns a raw const pointer to the float value for the specified uniform semantics.
This method retrieves the float value associated with a given `UniformSemantics` identifier. If no float value is associated with the specified semantics, the method returns `nullptr`.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
- Returns
A raw const pointer to the associated float value, or `nullptr` if no float value is associated with this semantics.
Definition at line 224 of file UniformValueMap.ixx.
int_ptr()
| inline nodiscard noexcept |
Returns a raw const pointer to the integer value for the specified uniform semantics.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
- Returns
A raw const pointer to the associated integer value, or `nullptr` if no integer value is associated with this semantics.
Definition at line 249 of file UniformValueMap.ixx.
mat4f()
| inline nodiscard noexcept |
Returns a const pointer to the `mat4f` value for the specified uniform semantics.
Unlike `mat4f_ptr()`, this returns a pointer to the `mat4f` object itself rather than its underlying float array.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
- Returns
A const pointer to the associated `mat4f`, or `nullptr` if no mat4f is associated with this semantics.
Definition at line 140 of file UniformValueMap.ixx.
mat4f_ptr()
| inline nodiscard noexcept |
Returns a raw const pointer to the `mat4f` for the specified uniform semantics.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
- Returns
A raw const pointer to the associated mat4f, or `nullptr` if no mat4f is associated with this semantics.
Definition at line 112 of file UniformValueMap.ixx.
set()
| inline noexcept |
Sets or updates a `helios::math::mat4f` uniform value for a given semantic.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
mat4f A const ref to the mat4f value to set.
Definition at line 100 of file UniformValueMap.ixx.
set()
| inline noexcept |
Sets or updates a `helios::math::vec4f` uniform value for a given semantic.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
vec4f A const ref to the vec4f value to set.
Definition at line 163 of file UniformValueMap.ixx.
set()
| inline noexcept |
Sets or updates an integer uniform value for a given semantic.
Typically used for texture unit indices.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
value The integer value to set.
Definition at line 199 of file UniformValueMap.ixx.
set()
| inline noexcept |
Sets or updates a float uniform value for a given semantic.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
value The float value to set.
Definition at line 209 of file UniformValueMap.ixx.
vec4f_ptr()
| inline nodiscard noexcept |
Returns a raw const pointer to the `vec4f` for the specified uniform semantics.
- Parameters
-
uniformSemantics The `UniformSemantics` identifier for the uniform.
- Returns
A raw const pointer to the associated vec4f, or `nullptr` if no vec4f is associated with this semantics.
Definition at line 174 of file UniformValueMap.ixx.
Private Member Attributes
map_
|
Internal data structure storing the association between a uniform semantic and a concrete value.
Definition at line 78 of file UniformValueMap.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.