nCine::GLShaderUniforms class

Manages the uniform caches of a shader program.

Owns a GLUniformCache for every active uniform of a shader program that is not part of a uniform block. It provides lookup by name, a shared data pointer setup, and a commit operation that uploads all dirty uniforms to the GL. The set of managed uniforms can be restricted to an include-only or exclude list.

Public types

using UniformHashMapType = StaticHashMap<String, GLUniformCache, UniformCachesHashSize, FNV1aHashFunc<String>>

Public static variables

static std::uint32_t UniformCachesHashSize constexpr
Number of buckets in the uniform cache hashmap.

Constructors, destructors, conversion operators

GLShaderUniforms()
Creates an instance not associated with any shader program.
GLShaderUniforms(GLShaderProgram* shaderProgram) explicit
Creates an instance importing all uniforms of the specified shader program.
GLShaderUniforms(GLShaderProgram* shaderProgram, const char* includeOnly, const char* exclude)
Creates an instance importing a filtered subset of the uniforms of the shader program.

Public functions

void SetProgram(GLShaderProgram* shaderProgram)
Associates a shader program and imports all of its uniforms.
void SetProgram(GLShaderProgram* shaderProgram, const char* includeOnly, const char* exclude)
Associates a shader program and imports a filtered subset of its uniforms.
void SetUniformsDataPointer(GLubyte* dataPointer)
Distributes a single host-side data buffer across the managed uniform caches.
void SetDirty(bool isDirty)
Sets the dirty flag of all managed uniform caches.
auto GetUniformCount() const -> std::uint32_t
Returns the number of managed uniforms.
auto HasUniform(const char* name) const -> bool
Returns whether a uniform with the specified name is managed.
auto GetUniform(const char* name) -> GLUniformCache*
Returns the uniform cache with the specified name, or nullptr if not found.
auto GetAllUniforms() const -> const UniformHashMapType
Returns the hashmap of all managed uniform caches.
void CommitUniforms()
Uses the program and uploads all dirty uniforms to the GL.