Skip to main content

OpenGLUniformWriter Class

Executes typed uniform uploads based on pre-resolved OpenGL locations. More...

Declaration

class helios::opengl::OpenGLUniformWriter { ... }

Public Static Functions Index

template <typename TUniformScope>
static voidwrite (std::span< OpenGLUniformWriteOperation > operations, UniformValueBag< TUniformScope > &uniformValueBag) noexcept

Writes uniform values for a specific scope to OpenGL. More...

Description

Executes typed uniform uploads based on pre-resolved OpenGL locations.

Definition at line 27 of file OpenGLUniformWriter.ixx.

Public Static Functions

write()

template <typename TUniformScope>
void helios::opengl::OpenGLUniformWriter::write (std::span< OpenGLUniformWriteOperation > operations, UniformValueBag< TUniformScope > & uniformValueBag)
inline noexcept static

Writes uniform values for a specific scope to OpenGL.

Iterates over prepared write operations, skips invalid locations (-1), maps semantics to supported uniform types, and submits the matching glUniform* call when the value exists in uniformValueBag.

Template Parameters
TUniformScope

Uniform lifetime scope tag (for example pass or draw).

Parameters
operations

Sequence of resolved OpenGL uniform write operations.

uniformValueBag

Typed uniform values used as upload source.

Definition at line 44 of file OpenGLUniformWriter.ixx.

44 static void write(
45 std::span<OpenGLUniformWriteOperation> operations,
46 UniformValueBag<TUniformScope>& uniformValueBag
47 ) noexcept {
48
49 for (std::size_t i = 0; i < operations.size(); ++i) {
50 auto& op = operations[i];
51 GLint location = op.location;
52 if (location == -1) {
53 continue;
54 }
55
56 auto semantics = static_cast<UniformSemantics>(op.semantics);
57 switch (semantics) {
58 case UniformSemantics::ViewMatrix:
59 if (uniformValueBag.template has<ViewMatrixUniform>()) {
60 glUniformMatrix4fv(location, 1, false,
61 helios::math::value_ptr(uniformValueBag.template get<ViewMatrixUniform>()));
62 }
63 break;
64 case UniformSemantics::ProjectionMatrix:
65 if (uniformValueBag.template has<ProjectionMatrixUniform>()) {
66 glUniformMatrix4fv(location, 1, false,
67 helios::math::value_ptr(uniformValueBag.template get<ProjectionMatrixUniform>()));
68 }
69 break;
70 case UniformSemantics::ModelMatrix:
71 if (uniformValueBag.template has<ModelMatrixUniform>()) {
72 glUniformMatrix4fv(location, 1, false,
73 helios::math::value_ptr(uniformValueBag.template get<ModelMatrixUniform>()));
74 }
75 break;
76 case UniformSemantics::MaterialBaseColor:
77 if (uniformValueBag.template has<MaterialBaseColorUniform>()) {
78 glUniform4fv(location, 1,
79 helios::math::value_ptr(uniformValueBag.template get<MaterialBaseColorUniform>()));
80 }
81 break;
82 default:
83 assert(false && "Missing support for Uniform");
84 break;
85 }
86
87 }
88
89 }

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.