galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::graphics::VertexArray Class Referencefinal

Abstraction for OpenGL vertex array objects. More...

#include <VertexArray.hpp>

+ Collaboration diagram for galaxy::graphics::VertexArray:

Public Member Functions

 VertexArray ()
 Constructor.
 
 VertexArray (VertexArray &&)
 Move constructor.
 
VertexArrayoperator= (VertexArray &&)
 Move assignment operator.
 
 ~VertexArray ()
 Destructor.
 
void buffer (std::span< Vertex > vertices, std::span< unsigned int > indicies)
 Create vertex array object.
 
void buffer (const int vertex_count, std::span< unsigned int > indicies)
 Create vertex array without uploading data.
 
void sub_buffer (const unsigned int index, std::span< Vertex > vertices)
 Sub-buffer vertex array.
 
void set_instanced (const InstanceBuffer &ib)
 Set this vertex array to use a specific instance buffer.
 
void bind ()
 Bind this vertex array.
 
void unbind ()
 Unbind this vertex array.
 
int count () const
 Get the index count.
 
void * offset ()
 Gets index offset.
 
int instances () const
 Number of instances to render.
 
VertexBuffervbo ()
 Get vertex buffer.
 
unsigned int id () const
 Get vertex array handle.
 

Private Member Functions

 VertexArray (const VertexArray &)=delete
 Copy constructor.
 
VertexArrayoperator= (const VertexArray &)=delete
 Copy assignment operator.
 

Private Attributes

unsigned int m_id
 VAO object.
 
VertexBuffer m_vbo
 Vertex buffer.
 
int m_instances
 Number of instances.
 

Detailed Description

Abstraction for OpenGL vertex array objects.

Definition at line 21 of file VertexArray.hpp.

Constructor & Destructor Documentation

◆ VertexArray() [1/3]

galaxy::graphics::VertexArray::VertexArray ( )

Constructor.

Definition at line 18 of file VertexArray.cpp.

◆ VertexArray() [2/3]

galaxy::graphics::VertexArray::VertexArray ( VertexArray && v)

Move constructor.

Definition at line 25 of file VertexArray.cpp.

◆ ~VertexArray()

galaxy::graphics::VertexArray::~VertexArray ( )

Destructor.

Definition at line 58 of file VertexArray.cpp.

◆ VertexArray() [3/3]

galaxy::graphics::VertexArray::VertexArray ( const VertexArray & )
privatedelete

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

VertexArray & galaxy::graphics::VertexArray::operator= ( VertexArray && v)

Move assignment operator.

Definition at line 39 of file VertexArray.cpp.

◆ buffer() [1/2]

void galaxy::graphics::VertexArray::buffer ( std::span< Vertex > vertices,
std::span< unsigned int > indicies )

Create vertex array object.

Parameters
verticesVertices to assign.
indiciesIndices for vertex buffer.

Definition at line 66 of file VertexArray.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buffer() [2/2]

void galaxy::graphics::VertexArray::buffer ( const int vertex_count,
std::span< unsigned int > indicies )

Create vertex array without uploading data.

Parameters
vertex_countSize of vertices.
indiciesIndices for vertex buffer.

Definition at line 86 of file VertexArray.cpp.

+ Here is the call graph for this function:

◆ sub_buffer()

void galaxy::graphics::VertexArray::sub_buffer ( const unsigned int index,
std::span< Vertex > vertices )

Sub-buffer vertex array.

Parameters
indexOffset to start at from initial vertices. 0 = first element.
verticesVertices to assign.

Definition at line 106 of file VertexArray.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set_instanced()

void galaxy::graphics::VertexArray::set_instanced ( const InstanceBuffer & ib)

Set this vertex array to use a specific instance buffer.

Parameters
ibInstance buffer to use. Does not take ownership, you need to keep it around.

Definition at line 111 of file VertexArray.cpp.

+ Here is the call graph for this function:

◆ bind()

void galaxy::graphics::VertexArray::bind ( )

Bind this vertex array.

Definition at line 138 of file VertexArray.cpp.

+ Here is the caller graph for this function:

◆ unbind()

void galaxy::graphics::VertexArray::unbind ( )

Unbind this vertex array.

Definition at line 143 of file VertexArray.cpp.

◆ count()

int galaxy::graphics::VertexArray::count ( ) const
nodiscard

Get the index count.

Returns
Integer.

Definition at line 148 of file VertexArray.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ offset()

void * galaxy::graphics::VertexArray::offset ( )
nodiscard

Gets index offset.

Returns
Integer as void pointer for opengl shenanigans.

Definition at line 153 of file VertexArray.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ instances()

int galaxy::graphics::VertexArray::instances ( ) const
nodiscard

Number of instances to render.

Returns
Integer.

Definition at line 158 of file VertexArray.cpp.

+ Here is the caller graph for this function:

◆ vbo()

VertexBuffer & galaxy::graphics::VertexArray::vbo ( )
nodiscard

Get vertex buffer.

Returns
Reference to vertex buffer object.

Definition at line 163 of file VertexArray.cpp.

+ Here is the caller graph for this function:

◆ id()

unsigned int galaxy::graphics::VertexArray::id ( ) const
nodiscard

Get vertex array handle.

Returns
Unsigned int.

Definition at line 168 of file VertexArray.cpp.

+ Here is the caller graph for this function:

◆ operator=() [2/2]

VertexArray & galaxy::graphics::VertexArray::operator= ( const VertexArray & )
privatedelete

Copy assignment operator.

Member Data Documentation

◆ m_id

unsigned int galaxy::graphics::VertexArray::m_id
private

VAO object.

Definition at line 140 of file VertexArray.hpp.

◆ m_vbo

VertexBuffer galaxy::graphics::VertexArray::m_vbo
private

Vertex buffer.

Definition at line 145 of file VertexArray.hpp.

◆ m_instances

int galaxy::graphics::VertexArray::m_instances
private

Number of instances.

Definition at line 150 of file VertexArray.hpp.


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