GLBufferObject class
#include <nCine/Graphics/GL/GLBufferObject.h>
Wraps an OpenGL buffer object.
Manages the lifetime of a single OpenGL buffer object bound to a given target (e.g. a VBO, IBO or UBO). Binding is cached per target so that redundant glBindBuffer() calls are skipped, and indexed binding state (base/range) is tracked for uniform buffers. Provides data upload, immutable storage allocation and persistent mapping.
Constructors, destructors, conversion operators
- GLBufferObject(GLenum target) explicit
- ~GLBufferObject()
Public functions
- auto GetGLHandle() const -> GLuint
- Returns the OpenGL handle of the buffer object.
- auto GetTarget() const -> GLenum
- Returns the target this buffer is bound to (e.g.
GL_ARRAY_BUFFER). - auto GetSize() const -> GLsizeiptr
- Returns the size in bytes of the data store, as last set by BufferData() or BufferStorage().
- auto Bind() const -> bool
- Binds the buffer to its target.
- auto Unbind() const -> bool
- Unbinds any buffer from this object's target.
- void BufferData(GLsizeiptr size, const GLvoid* data, GLenum usage)
- Creates and initializes the data store with the given size, optional data and usage hint.
- void BufferSubData(GLintptr offset, GLsizeiptr size, const GLvoid* data)
- Updates a subset of the data store starting at the given byte offset.
- void BufferStorage(GLsizeiptr size, const GLvoid* data, GLbitfield flags)
- Allocates an immutable data store with the given size, optional data and storage flags.
- void BindBufferBase(GLuint index)
- Binds the whole buffer to a binding point index of the (uniform) buffer target.
- void BindBufferRange(GLuint index, GLintptr offset, GLsizei ptrsize)
- Binds a byte range of the buffer to a binding point index of the (uniform) buffer target.
- auto MapBufferRange(GLintptr offset, GLsizeiptr length, GLbitfield access) -> void*
- Maps a byte range of the buffer into client memory and returns the pointer.
- void FlushMappedBufferRange(GLintptr offset, GLsizeiptr length)
- Flushes a byte range of the currently mapped buffer.
- auto Unmap() -> GLboolean
- Unmaps the previously mapped buffer.
- void TexBuffer(GLenum internalformat)
- Attaches the buffer storage to the active texture as a texture buffer with the given internal format.
- void SetObjectLabel(StringView label)
- Sets an OpenGL object label for the buffer, for debugging.
Function documentation
bool nCine:: GLBufferObject:: Bind() const
Binds the buffer to its target.
| Returns | true if a glBindBuffer() call was issued, false if it was already bound |
|---|
bool nCine:: GLBufferObject:: Unbind() const
Unbinds any buffer from this object's target.
| Returns | true if a glBindBuffer() call was issued, false if nothing was bound |
|---|
GLboolean nCine:: GLBufferObject:: Unmap()
Unmaps the previously mapped buffer.
| Returns | GL_FALSE if the buffer contents became corrupt while mapped |
|---|