nCine::GLShaderUniformBlocks class

Manages the uniform block caches of a shader program.

Owns a GLUniformBlockCache for every active uniform block of a shader program. It provides lookup by name, a shared data pointer setup, a commit operation that copies the block contents into a uniform buffer, and a bind operation that binds the buffer ranges. The set of managed blocks can be restricted to an include-only or exclude list.

Public types

using UniformHashMapType = StaticHashMap<String, GLUniformBlockCache, UniformBlockCachesHashSize>

Public static variables

static std::int32_t UniformBlockCachesHashSize constexpr
Number of buckets in the uniform block cache hashmap.

Constructors, destructors, conversion operators

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

Public functions

void SetProgram(GLShaderProgram* shaderProgram)
Associates a shader program and imports all of its uniform blocks.
void SetProgram(GLShaderProgram* shaderProgram, const char* includeOnly, const char* exclude)
Associates a shader program and imports a filtered subset of its uniform blocks.
void SetUniformsDataPointer(GLubyte* dataPointer)
Distributes a single host-side data buffer across the managed uniform block caches.
auto GetUniformBlockCount() const -> unsigned int
Returns the number of managed uniform blocks.
auto HasUniformBlock(const char* name) const -> bool
Returns whether a uniform block with the specified name is managed.
auto GetUniformBlock(const char* name) -> GLUniformBlockCache*
Returns the uniform block cache with the specified name, or nullptr if not found.
auto GetAllUniformBlocks() const -> const UniformHashMapType
Returns the hashmap of all managed uniform block caches.
void CommitUniformBlocks()
Copies the managed blocks into a uniform buffer acquired from the buffers manager.
void Bind()
Binds the uniform buffer ranges of the managed blocks for rendering.