Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::OpenGL::UniformBufferObject Class Reference

Wraps a UBO with a BufferLayout for structured writes. More...

#include <spk_uniform_buffer_object.hpp>

Inheritance diagram for spk::OpenGL::UniformBufferObject:
Inheritance graph
Collaboration diagram for spk::OpenGL::UniformBufferObject:
Collaboration graph

Public Member Functions

 UniformBufferObject (GLuint p_bindingPoint, BufferObject::Usage p_usage, const size_t &p_size)
 Creates a UBO bound to a binding point.
 UniformBufferObject (const UniformBufferObject &p_other)
 Copies layout and buffer binding information from another UBO.
UniformBufferObjectoperator= (const UniformBufferObject &p_other)
 Copies layout and buffer binding information from another UBO.
BufferLayoutlayout ()
 Accesses the layout describing the UBO contents.
const BufferLayoutlayout () const
 Accesses the layout describing the UBO contents.
template<typename TType>
TType pull () const
 Reads the entire UBO content as a trivially copyable type.
BufferLayout::Elementoperator[] (const std::wstring &p_name)
 Accesses a named field within the layout.
const BufferLayout::Elementoperator[] (const std::wstring &p_name) const
 Accesses a named field within the layout.
Buffer::value_type * data ()
 Mutable pointer to underlying bytes.
const Buffer::value_type * data () const
 Const pointer to underlying bytes.
size_t size () const
 Returns the current CPU buffer size.

Detailed Description

Wraps a UBO with a BufferLayout for structured writes.

See also
BufferLayout, ShaderStorageBufferObject

Constructor & Destructor Documentation

◆ UniformBufferObject() [1/2]

spk::OpenGL::UniformBufferObject::UniformBufferObject ( GLuint p_bindingPoint,
BufferObject::Usage p_usage,
const size_t & p_size )

Creates a UBO bound to a binding point.

Parameters
p_bindingPointBinding index.
p_usageUsage hint.
p_sizeInitial buffer size.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UniformBufferObject() [2/2]

spk::OpenGL::UniformBufferObject::UniformBufferObject ( const UniformBufferObject & p_other)

Copies layout and buffer binding information from another UBO.

Parameters
p_otherSource buffer.
Here is the call graph for this function:

Member Function Documentation

◆ data() [1/2]

BufferObject::Buffer::value_type * spk::OpenGL::BufferObject::data ( )

Mutable pointer to underlying bytes.

Returns
Pointer or nullptr if empty.

◆ data() [2/2]

const BufferObject::Buffer::value_type * spk::OpenGL::BufferObject::data ( ) const

Const pointer to underlying bytes.

Returns
Pointer or nullptr if empty.

◆ layout() [1/2]

BufferLayout & spk::OpenGL::UniformBufferObject::layout ( )

Accesses the layout describing the UBO contents.

Returns
Mutable layout.

◆ layout() [2/2]

const BufferLayout & spk::OpenGL::UniformBufferObject::layout ( ) const

Accesses the layout describing the UBO contents.

Returns
Const layout.

◆ operator=()

UniformBufferObject & spk::OpenGL::UniformBufferObject::operator= ( const UniformBufferObject & p_other)

Copies layout and buffer binding information from another UBO.

Parameters
p_otherSource buffer.
Returns
Reference to this.
Here is the call graph for this function:

◆ operator[]() [1/2]

BufferLayout::Element & spk::OpenGL::UniformBufferObject::operator[] ( const std::wstring & p_name)

Accesses a named field within the layout.

Parameters
p_nameElement identifier.
Returns
Mutable layout element.

◆ operator[]() [2/2]

const BufferLayout::Element & spk::OpenGL::UniformBufferObject::operator[] ( const std::wstring & p_name) const

Accesses a named field within the layout.

Parameters
p_nameElement identifier.
Returns
Const layout element.

◆ pull()

template<typename TType>
TType spk::OpenGL::UniformBufferObject::pull ( ) const
inline

Reads the entire UBO content as a trivially copyable type.

Template Parameters
TTypeTrivially copyable type expected in the buffer.
Returns
Copy of the GPU buffer cast to the requested type.
Exceptions
std::runtime_errorWhen the GPU buffer is smaller than the requested type.

◆ size()

size_t spk::OpenGL::BufferObject::size ( ) const

Returns the current CPU buffer size.

Returns
Byte size.

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