Skip to main content

PlottingOpenGL::GLSSBOBuffer

PlottingOpenGL::GLSSBOBuffer

RAII wrapper for a GL_SHADER_STORAGE_BUFFER. More…

#include <GLSSBOBuffer.hpp>

Public Functions

Name
GLSSBOBuffer() =default
~GLSSBOBuffer()
GLSSBOBuffer(GLSSBOBuffer const & ) =delete
GLSSBOBuffer & operator=(GLSSBOBuffer const & ) =delete
GLSSBOBuffer(GLSSBOBuffer && other)
GLSSBOBuffer & operator=(GLSSBOBuffer && other)
bool create()
Create the underlying GL buffer object. Returns true on success.
void destroy()
Destroy the GL buffer object (safe to call even if not created).
bool isCreated() const
std::uint32_t bufferId() const
void allocate(void const * data, int size_bytes)
Allocate and optionally fill the buffer.
void write(int offset_bytes, void const * data, int size_bytes)
Write into an existing allocation without reallocating.
void bindBase(std::uint32_t binding) const
Bind this buffer to a numbered SSBO binding point.
int size() const
void * mapReadOnly() const
Map the buffer for CPU read-back (GL_READ_ONLY).
void unmap() const
Unmap a previously mapped buffer.

Detailed Description

class PlottingOpenGL::GLSSBOBuffer;

RAII wrapper for a GL_SHADER_STORAGE_BUFFER.

Manages a single SSBO with create / upload / partial-write / bind-base operations. Destruction releases the GL resource.

All methods require a current OpenGL context.

Public Functions Documentation

function GLSSBOBuffer

GLSSBOBuffer() =default

function ~GLSSBOBuffer

~GLSSBOBuffer()

function GLSSBOBuffer

GLSSBOBuffer(
    GLSSBOBuffer const & 
) =delete

function operator=

GLSSBOBuffer & operator=(
    GLSSBOBuffer const & 
) =delete

function GLSSBOBuffer

GLSSBOBuffer(
    GLSSBOBuffer && other
)

function operator=

GLSSBOBuffer & operator=(
    GLSSBOBuffer && other
)

function create

bool create()

Create the underlying GL buffer object. Returns true on success.

function destroy

void destroy()

Destroy the GL buffer object (safe to call even if not created).

function isCreated

inline bool isCreated() const

Return: true if the buffer has been created and is valid.

function bufferId

inline std::uint32_t bufferId() const

Return: The raw GL buffer name (0 if not created).

function allocate

void allocate(
    void const * data,
    int size_bytes
)

Allocate and optionally fill the buffer.

Parameters:

  • data Pointer to source data, or nullptr for uninitialized allocation.
  • size_bytes Total size in bytes to allocate.

Uses GL_DYNAMIC_DRAW since these buffers are updated periodically.

function write

void write(
    int offset_bytes,
    void const * data,
    int size_bytes
)

Write into an existing allocation without reallocating.

Parameters:

  • offset_bytes Byte offset from the start of the buffer.
  • data Pointer to source data.
  • size_bytes Number of bytes to write.

function bindBase

void bindBase(
    std::uint32_t binding
) const

Bind this buffer to a numbered SSBO binding point.

Equivalent to glBindBufferBase(GL_SHADER_STORAGE_BUFFER, binding, m_buffer_id).

function size

inline int size() const

Return: Current allocated size in bytes (as reported by GL).

function mapReadOnly

void * mapReadOnly() const

Map the buffer for CPU read-back (GL_READ_ONLY).

Return: Pointer to mapped memory, or nullptr on failure. Caller must call unmap() when done.

function unmap

void unmap() const

Unmap a previously mapped buffer.


Updated on 2026-11-13 at 20:25:41 +0000