lmgl 1.0.0
A lightweight OpenGL graphics engine library written in C++
Loading...
Searching...
No Matches
lmgl::renderer::VertexBuffer Class Reference

Manages a vertex buffer in OpenGL. More...

#include <buffer.hpp>

Public Member Functions

 VertexBuffer (const void *vertices, unsigned int size, bool dynamic=false)
 Constructor for the VertexBuffer.
 
 ~VertexBuffer ()
 Destructor for the VertexBuffer.
 
void bind () const
 Bind the vertex buffer.
 
void unbind () const
 Unbind the vertex buffer.
 
void set_data (const void *data, unsigned int size)
 Set the data of the vertex buffer.
 
void set_layout (const BufferLayout &layout)
 Set the layout of the vertex buffer.
 
const BufferLayoutget_layout () const
 Get the layout of the vertex buffer.
 

Detailed Description

Manages a vertex buffer in OpenGL.

This class encapsulates the creation, binding, and management of a vertex buffer. It allows for dynamic or static data storage and provides methods to set data and retrieve the buffer layout.

Note
The buffer is identified by a renderer ID assigned by OpenGL.

Constructor & Destructor Documentation

◆ VertexBuffer()

lmgl::renderer::VertexBuffer::VertexBuffer ( const void * vertices,
unsigned int size,
bool dynamic = false )

Constructor for the VertexBuffer.

Initializes the vertex buffer with the provided vertex data and size. The buffer can be created as dynamic or static based on the 'dynamic' flag.

Parameters
verticesPointer to the vertex data.
sizeSize of the vertex data in bytes.
dynamicIndicates if the buffer is dynamic (default is false).

Member Function Documentation

◆ bind()

void lmgl::renderer::VertexBuffer::bind ( ) const

Bind the vertex buffer.

Activates the vertex buffer for subsequent rendering operations.

◆ get_layout()

const BufferLayout & lmgl::renderer::VertexBuffer::get_layout ( ) const

Get the layout of the vertex buffer.

Returns a constant reference to the BufferLayout that describes the structure of the vertex data in the buffer.

Returns
Constant reference to the BufferLayout.

◆ set_data()

void lmgl::renderer::VertexBuffer::set_data ( const void * data,
unsigned int size )

Set the data of the vertex buffer.

Updates the contents of the vertex buffer with new data.

Parameters
dataPointer to the new vertex data.
sizeSize of the new vertex data in bytes.

◆ set_layout()

void lmgl::renderer::VertexBuffer::set_layout ( const BufferLayout & layout)

Set the layout of the vertex buffer.

Assigns a BufferLayout to the vertex buffer, defining the structure of the vertex data.

Parameters
layoutThe BufferLayout to be assigned to the vertex buffer.

◆ unbind()

void lmgl::renderer::VertexBuffer::unbind ( ) const

Unbind the vertex buffer.

Deactivates the vertex buffer.


The documentation for this class was generated from the following files: