GLUniformCache class
#include <nCine/Graphics/GL/GLUniformCache.h>
Caches the value of a single uniform and uploads it to the shader.
Holds a host-side data pointer for one GLUniform and the Set* methods that write values into it. A dirty flag tracks whether the cached value differs from what was last uploaded; CommitValue() then flushes it to the GL with the appropriate glUniform* call, avoiding redundant uploads. The cache must reference a uniform that is not part of a uniform block.
Constructors, destructors, conversion operators
- GLUniformCache()
- Creates an empty cache not associated with any uniform.
- GLUniformCache(const GLUniform* uniform) explicit
- Creates a cache for the specified uniform.
Public functions
- auto GetUniform() const -> const GLUniform*
- Returns the uniform described by this cache.
- auto GetDataPointer() const -> const GLubyte*
- Returns the host-side data pointer holding the cached value.
- void SetDataPointer(GLubyte* dataPointer)
- Sets the host-side data pointer holding the cached value.
- auto GetFloatVector() const -> const GLfloat*
- Returns the cached value as a float vector, or
nullptrif unavailable. -
auto GetFloatValue(std::
uint32_t index) const -> GLfloat - Returns the float component at the specified index.
- auto GetIntVector() const -> const GLint*
- Returns the cached value as an integer vector, or
nullptrif unavailable. -
auto GetIntValue(std::
uint32_t index) const -> GLint - Returns the integer component at the specified index.
- auto SetFloatVector(const GLfloat* vec) -> bool
- Sets the cached value from a float vector and returns whether it succeeded.
- auto SetFloatValue(GLfloat v0) -> bool
- Sets a single-component float value and returns whether it succeeded.
- auto SetFloatValue(GLfloat v0, GLfloat v1) -> bool
- Sets a two-component float value and returns whether it succeeded.
- auto SetFloatValue(GLfloat v0, GLfloat v1, GLfloat v2) -> bool
- Sets a three-component float value and returns whether it succeeded.
- auto SetFloatValue(GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) -> bool
- Sets a four-component float value and returns whether it succeeded.
- auto SetIntVector(const GLint* vec) -> bool
- Sets the cached value from an integer vector and returns whether it succeeded.
- auto SetIntValue(GLint v0) -> bool
- Sets a single-component integer value and returns whether it succeeded.
- auto SetIntValue(GLint v0, GLint v1) -> bool
- Sets a two-component integer value and returns whether it succeeded.
- auto SetIntValue(GLint v0, GLint v1, GLint v2) -> bool
- Sets a three-component integer value and returns whether it succeeded.
- auto SetIntValue(GLint v0, GLint v1, GLint v2, GLint v3) -> bool
- Sets a four-component integer value and returns whether it succeeded.
- auto IsDirty() const -> bool
- Returns whether the cached value still needs to be committed to the GL.
- void SetDirty(bool isDirty)
- Sets the dirty flag controlling whether the value is committed.
- auto CommitValue() -> bool
- Uploads the cached value to the shader if it is dirty.
Function documentation
bool nCine:: GLUniformCache:: CommitValue()
Uploads the cached value to the shader if it is dirty.
Issues the matching glUniform* call for the uniform type and clears the dirty flag. Does nothing and returns false if there is no value, no data pointer or the value is not dirty.