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

Class representing a Vertex Array Object (VAO) in OpenGL. More...

#include <vertex_array.hpp>

Public Member Functions

 VertexArray ()
 Constructs a new Vertex Array Object (VAO)
 
 ~VertexArray ()
 Destructor to clean up the VAO.
 
void bind () const
 Binds the Vertex Array Object for rendering.
 
void unbind () const
 Unbinds the Vertex Array Object.
 
void add_vertex_buffer (const std::shared_ptr< VertexBuffer > &vertex_buffer)
 Adds a Vertex Buffer to the Vertex Array Object.
 
void set_index_buffer (const std::shared_ptr< IndexBuffer > &index_buffer)
 Sets the Index Buffer for the Vertex Array Object.
 
const std::vector< std::shared_ptr< VertexBuffer > > & get_vertex_buffers () const
 Retrieves the list of Vertex Buffers associated with the Vertex Array Object.
 
const std::shared_ptr< IndexBuffer > & get_index_buffer () const
 Retrieves the Index Buffer associated with the Vertex Array Object.
 

Detailed Description

Class representing a Vertex Array Object (VAO) in OpenGL.

This class encapsulates the functionality of a VAO, allowing for the management of vertex and index buffers used in rendering operations.

Note
This class assumes the existence of VertexBuffer and IndexBuffer classes defined in "buffer.hpp".

Member Function Documentation

◆ add_vertex_buffer()

void lmgl::renderer::VertexArray::add_vertex_buffer ( const std::shared_ptr< VertexBuffer > & vertex_buffer)

Adds a Vertex Buffer to the Vertex Array Object.

This method associates a Vertex Buffer with the VAO, allowing it to be used for rendering.

Parameters
vertexBufferA shared pointer to the Vertex Buffer to be added.

◆ bind()

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

Binds the Vertex Array Object for rendering.

This method makes the VAO active so that subsequent rendering commands use it.

Note
Ensure to call unbind() after rendering to avoid unintended side effects.

◆ get_index_buffer()

const std::shared_ptr< IndexBuffer > & lmgl::renderer::VertexArray::get_index_buffer ( ) const

Retrieves the Index Buffer associated with the Vertex Array Object.

This method returns a shared pointer to the Index Buffer.

Returns
A shared pointer to the Index Buffer.

◆ get_vertex_buffers()

const std::vector< std::shared_ptr< VertexBuffer > > & lmgl::renderer::VertexArray::get_vertex_buffers ( ) const

Retrieves the list of Vertex Buffers associated with the Vertex Array Object.

This method returns a constant reference to a vector containing shared pointers to the Vertex Buffers.

Returns
A constant reference to a vector of shared pointers to the Vertex Buffers.

◆ set_index_buffer()

void lmgl::renderer::VertexArray::set_index_buffer ( const std::shared_ptr< IndexBuffer > & index_buffer)

Sets the Index Buffer for the Vertex Array Object.

This method associates an Index Buffer with the VAO, enabling indexed rendering.

Parameters
indexBufferA shared pointer to the Index Buffer to be set.

◆ unbind()

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

Unbinds the Vertex Array Object.

This method deactivates the VAO, preventing it from being used in subsequent rendering commands.

Note
It is good practice to unbind the VAO after rendering to maintain a clean state.

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