Ocular Engine
Ocular::Graphics::UniformBuffer Class Reference

Generic buffer for storing and binding of shader uniforms. More...

#include <UniformBuffer.hpp>

Inheritance diagram for Ocular::Graphics::UniformBuffer:
Ocular::Graphics::D3D11UniformBuffer

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< Uniformm_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.
 

Detailed Description

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.

Member Function Documentation

uint32_t Ocular::Graphics::UniformBuffer::getNumUniforms ( ) const
Returns
Returns the number of individual uniforms in this UniformBuffer
Uniform const * Ocular::Graphics::UniformBuffer::getUniform ( std::string const &  name) const
Note
Only available to dynamic buffers (Material)
Uniform const * Ocular::Graphics::UniformBuffer::getUniform ( uint32_t  registerIndex) const
Note
Only available to dynamic buffers (Material)
uint32_t Ocular::Graphics::UniformBuffer::getUniformsSize ( ) const
Returns
The total size of the UniformBuffer on the GPU
void Ocular::Graphics::UniformBuffer::setUniform ( Uniform const &  uniform)
Note
Only available to dynamic buffers (Material)

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