Ocular Engine
|
Generic buffer for storing and binding of shader uniforms. More...
#include <UniformBuffer.hpp>
Public Member Functions | |
UniformBuffer (UniformBufferType type) | |
virtual void | bind () |
virtual void | unbind () |
void | setFixedData (UniformPerFrame const &data) |
void | setFixedData (UniformPerCamera const &data) |
void | setFixedData (UniformPerObject const &data) |
void | setUniform (Uniform const &uniform) |
Uniform const * | getUniform (std::string const &name) const |
Uniform const * | getUniform (uint32_t registerIndex) const |
std::vector< Uniform > const * | getUniforms () const |
uint32_t | getNumUniforms () const |
uint32_t | getUniformsSize () const |
Protected Attributes | |
uint32_t | m_Type |
bool | m_IsDirty |
std::vector< Uniform > | m_Uniforms |
User-friendly copy of Uniform data that is easily modifiable. Strictly CPU-only. | |
float * | m_UniformData |
Raw, packed (16-byte) uniform data. Only modify when m_IsDirty is true and not in use by GPU. | |
uint32_t | m_UniformDataSize |
Size of the raw uniform data. | |
Generic buffer for storing and binding of shader uniforms.
Typically, the UniformBuffer class is only to be used internally by the engine. For most cases, per-Material uniform access is sufficient (see the family of Material::setUniform and Material::getUniform methods).
There is normally four different instances of UniformBuffers in use at any time by the Ocular engine. These are as follows:
Per-Frame (global values, lights, etc.) Per-Camera (view and projection matrices, eye position, etc.) Per-Object (world matrix, etc.) Per-Material (any user defined values)
All buffers except Material buffers are treated as 'fixed' while Materials are 'dynamic'. What this means is that fixed buffers take in full structs as data, while dynamic buffers can take in individual uniform values and registers. So a fixed uniform is rigid and the structure of it's data can never change.
See the manual section on Shaders for more information.
uint32_t Ocular::Graphics::UniformBuffer::getNumUniforms | ( | ) | const |
Uniform const * Ocular::Graphics::UniformBuffer::getUniform | ( | std::string const & | name | ) | const |
Uniform const * Ocular::Graphics::UniformBuffer::getUniform | ( | uint32_t | registerIndex | ) | const |
uint32_t Ocular::Graphics::UniformBuffer::getUniformsSize | ( | ) | const |
void Ocular::Graphics::UniformBuffer::setUniform | ( | Uniform const & | uniform | ) |