3#include "structure/container/spk_buffer_layout.hpp"
4#include "structure/opengl/spk_buffer_object.hpp"
5#include "structure/opengl/spk_opengl_includes.hpp"
6#include "utils/spk_opengl_utils.hpp"
23 GLuint _bindingPoint = 0;
74 template <
typename TType>
77 static_assert(std::is_trivially_copyable_v<TType>,
"UniformBufferObject::pull requires a trivially copyable type");
79 const auto rawData = spk::OpenGLUtils::readBuffer(
static_cast<GLenum
>(
_type),
static_cast<GLuint
>(
_id));
80 if (rawData.size() <
sizeof(TType))
82 throw std::runtime_error(
"UniformBufferObject::pull: GPU buffer is smaller than requested type");
86 std::memcpy(&value, rawData.data(),
sizeof(TType));
104 using UBO = UniformBufferObject;
void deactivate()
Sets the state to Deactivated.
Definition spk_activable_object.hpp:61
void activate()
Sets the state to Activated.
Definition spk_activable_object.hpp:54
bool isActive() const
Checks whether the object is currently activated.
Definition spk_activable_object.hpp:77
Node within a BufferLayout representing an object, array or leaf segment.
Definition spk_buffer_layout.hpp:65
Describes and writes typed data into a raw buffer with object/array hierarchy.
Definition spk_buffer_layout.hpp:26
spk::CachedData< GLuint > _id
Lazily created GPU buffer identifier.
Definition spk_buffer_object.hpp:91
Buffer::value_type * data()
Mutable pointer to underlying bytes.
Definition spk_buffer_object.cpp:183
Usage
Usage hints forwarded to the OpenGL driver.
Definition spk_buffer_object.hpp:61
BufferObject(const Type &p_type, const Usage &p_usage)
Constructs a buffer with target type and usage hint.
Definition spk_buffer_object.cpp:45
size_t size() const
Returns the current CPU buffer size.
Definition spk_buffer_object.cpp:168
Type _type
Buffer target selected at construction.
Definition spk_buffer_object.hpp:83
void _registerCallbacks()
Registers GPU lifecycle callbacks with the cached buffer id.
Definition spk_buffer_object.cpp:33
bool needsSynchronization() const noexcept
Checks if synchronization is pending.
Definition spk_synchronizable_object.hpp:32
void requestSynchronization() noexcept
Marks the object as needing synchronization.
Definition spk_synchronizable_object.hpp:23