Class Buffers
RAII base class for OpenGL buffer objects (GL_ARRAY_BUFFER family). More...
#include <Buffers.h>
Inherited by the following classes: IndexBuffer, StorageBuffer, UniformBuffer, VertexBuffer
Public Functions
| Type | Name |
|---|---|
| Buffers () = default |
|
| Buffers (const Buffers & buf) Copy constructor. Performs a GPU-side deep copy of buf . |
|
| Buffers (Buffers && buf) noexcept Move constructor. Transfers ownership from buf . |
|
| GLuint | GetID () const Returns the OpenGL buffer object ID. |
| GLuint | GetSize () const Returns the allocated buffer size in bytes. |
| Buffers & | operator= (const Buffers & buf) Copy assignment. Performs a GPU-side deep copy of buf . |
| Buffers & | operator= (Buffers && buf) noexcept Move assignment. Transfers ownership from buf . |
| ~Buffers () Destructor. Releases the OpenGL buffer object if valid. |
Protected Attributes
| Type | Name |
|---|---|
| GLuint | buf_ID = 0OpenGL buffer object ID (0 = invalid/empty) |
| GLuint | buf_size = 0Allocated buffer size in bytes. |
Protected Functions
| Type | Name |
|---|---|
| void | _deepCopyFrom (const Buffers & src) GPU-side deep copy from src . |
| void | _delBuffer () Deletes the OpenGL buffer object and resets buf_ID to 0. |
Detailed Description
Encapsulates a single OpenGL buffer object ID (buf_ID) and its allocated size (buf_size). Provides correct copy and move semantics so that derived buffer classes inherit safe resource management without duplicating boilerplate.
Copy semantics (deep copy):
VertexBuffer a(data);
VertexBuffer b = a; // new GPU buffer allocated; content copied via glCopyBufferSubData
Move semantics (ownership transfer):
VertexBuffer a(data);
VertexBuffer b = std::move(a); // b owns the buffer; a.GetID() == 0
Note:
Thread-safety: Not thread-safe. Must be used from the OpenGL context thread.
Note:
Only GL buffer objects (glGenBuffers) are managed here. Renderbuffers and framebuffers have separate RAII wrappers.
Public Functions Documentation
function Buffers [1/3]
Buffers::Buffers () = default
function Buffers [2/3]
Copy constructor. Performs a GPU-side deep copy of buf .
Buffers::Buffers (
const Buffers & buf
)
Parameters:
bufSource buffer.
function Buffers [3/3]
Move constructor. Transfers ownership from buf .
Buffers::Buffers (
Buffers && buf
) noexcept
Parameters:
bufSource buffer (left in the empty state, buf_ID = 0).
function GetID
Returns the OpenGL buffer object ID.
inline GLuint Buffers::GetID () const
Returns:
buf_ID (0 if the buffer is empty/invalid).
function GetSize
Returns the allocated buffer size in bytes.
inline GLuint Buffers::GetSize () const
Returns:
buf_size (0 if no data has been uploaded).
function operator=
Copy assignment. Performs a GPU-side deep copy of buf .
Buffers & Buffers::operator= (
const Buffers & buf
)
Parameters:
bufSource buffer.
Returns:
Reference to this.
function operator=
Move assignment. Transfers ownership from buf .
Buffers & Buffers::operator= (
Buffers && buf
) noexcept
Parameters:
bufSource buffer (left in the empty state).
Returns:
Reference to this.
function ~Buffers
Destructor. Releases the OpenGL buffer object if valid.
Buffers::~Buffers ()
Protected Attributes Documentation
variable buf_ID
OpenGL buffer object ID (0 = invalid/empty)
GLuint Buffers::buf_ID;
variable buf_size
Allocated buffer size in bytes.
GLuint Buffers::buf_size;
Protected Functions Documentation
function _deepCopyFrom
GPU-side deep copy from src .
void Buffers::_deepCopyFrom (
const Buffers & src
)
Allocates a new buffer of the same size and copies all content using glCopyBufferSubData (GL_COPY_READ_BUFFER → GL_COPY_WRITE_BUFFER). If src is empty (buf_ID == 0 or buf_size == 0) only the metadata is copied; no GPU allocation is performed.
Parameters:
srcSource buffer to copy from.
function _delBuffer
Deletes the OpenGL buffer object and resets buf_ID to 0.
void Buffers::_delBuffer ()
The documentation for this class was generated from the following file src/render/Buffers.h