SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::RenderEngine::OpenGLBuffer Class Reference

OpenGL VBO/EBO/UBO wrapper; target is derived from BufferType at construction. More...

#include <OpenGLBuffer.hpp>

Inheritance diagram for Sleak::RenderEngine::OpenGLBuffer:

Public Member Functions

 OpenGLBuffer (uint32_t size, BufferType type)
 ~OpenGLBuffer () override
void Cleanup () override
void * GetData () override
GLuint GetGLBuffer () const
GLenum GetTarget () const
bool Initialize (void *data) override
 Creates the GL buffer object and uploads the initial payload, if any.
bool Map () override
 Maps the buffer for direct CPU writes via glMapBuffer.
void Unmap () override
void Update () override
 Re-uploads the last-mapped/updated data via glBufferSubData.
void Update (void *data, size_t size) override
 Uploads new data, resizing the backing store if it grew.
Public Member Functions inherited from Sleak::RenderEngine::BufferBase
const void * GetCPUShadowCopy () const
size_t GetCPUShadowCopySize () const
size_t GetSize ()
int GetSlot () const
BufferType GetType ()
uint32_t GetVertexFormat () const
 Registered custom vertex layout of this buffer; 0 means the engine default Vertex.
void SetSlot (int slot)
void SetVertexFormat (uint32_t handle)
 Tags the buffer with a VertexFormatRegistry handle so backends pick the matching pipeline.
void StoreCPUShadowCopy (const void *data, size_t size)
 Copies up to 128 bytes into the inline shadow-copy storage, clamping oversized input.
Public Member Functions inherited from Sleak::ResourceBase
virtual ~ResourceBase ()=default

Additional Inherited Members

Protected Attributes inherited from Sleak::RenderEngine::BufferBase
bool bIsMapped = false
void * Data = nullptr
const void * m_cpuShadowCopy = nullptr
size_t m_cpuShadowCopySize = 0
char m_cpuShadowStorage [128] = {}
uint32_t m_vertexFormat = 0
size_t Size = 0
int Slot = 0
BufferType Type
Protected Attributes inherited from Sleak::ResourceBase
bool bIsInitialized
std::string Name

Detailed Description

OpenGL VBO/EBO/UBO wrapper; target is derived from BufferType at construction.

Definition at line 11 of file OpenGLBuffer.hpp.

Constructor & Destructor Documentation

◆ OpenGLBuffer()

Sleak::RenderEngine::OpenGLBuffer::OpenGLBuffer ( uint32_t size,
BufferType type )

Definition at line 8 of file OpenGLBuffer.cpp.

◆ ~OpenGLBuffer()

Sleak::RenderEngine::OpenGLBuffer::~OpenGLBuffer ( )
override

Definition at line 28 of file OpenGLBuffer.cpp.

Member Function Documentation

◆ Cleanup()

void Sleak::RenderEngine::OpenGLBuffer::Cleanup ( )
overridevirtual

Implements Sleak::ResourceBase.

Definition at line 67 of file OpenGLBuffer.cpp.

◆ GetData()

void * Sleak::RenderEngine::OpenGLBuffer::GetData ( )
overridevirtual

Implements Sleak::RenderEngine::BufferBase.

Definition at line 98 of file OpenGLBuffer.cpp.

◆ GetGLBuffer()

GLuint Sleak::RenderEngine::OpenGLBuffer::GetGLBuffer ( ) const
inline

Definition at line 30 of file OpenGLBuffer.hpp.

◆ GetTarget()

GLenum Sleak::RenderEngine::OpenGLBuffer::GetTarget ( ) const
inline

Definition at line 31 of file OpenGLBuffer.hpp.

◆ Initialize()

bool Sleak::RenderEngine::OpenGLBuffer::Initialize ( void * data)
overridevirtual

Creates the GL buffer object and uploads the initial payload, if any.

Implements Sleak::ResourceBase.

Definition at line 32 of file OpenGLBuffer.cpp.

◆ Map()

bool Sleak::RenderEngine::OpenGLBuffer::Map ( )
overridevirtual

Maps the buffer for direct CPU writes via glMapBuffer.

Implements Sleak::RenderEngine::BufferBase.

Definition at line 75 of file OpenGLBuffer.cpp.

◆ Unmap()

void Sleak::RenderEngine::OpenGLBuffer::Unmap ( )
overridevirtual

Implements Sleak::RenderEngine::BufferBase.

Definition at line 88 of file OpenGLBuffer.cpp.

◆ Update() [1/2]

void Sleak::RenderEngine::OpenGLBuffer::Update ( )
overridevirtual

Re-uploads the last-mapped/updated data via glBufferSubData.

Implements Sleak::RenderEngine::BufferBase.

Definition at line 47 of file OpenGLBuffer.cpp.

◆ Update() [2/2]

void Sleak::RenderEngine::OpenGLBuffer::Update ( void * data,
size_t size )
overridevirtual

Uploads new data, resizing the backing store if it grew.

Implements Sleak::RenderEngine::BufferBase.

Definition at line 54 of file OpenGLBuffer.cpp.