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::VertexBatch Class Referencefinal

Batches together vertex data to reduce draw calls. More...

#include <VertexBatch.hpp>

+ Collaboration diagram for galaxy::graphics::VertexBatch:

Public Member Functions

 VertexBatch ()
 Constructor.
 
 VertexBatch (VertexBatch &&)
 Move constructor.
 
VertexBatchoperator= (VertexBatch &&)
 Move assignment operator.
 
 ~VertexBatch ()
 Destructor.
 
void init (const int max_quads)
 Initialize vertex batch data.
 
int push (std::span< Vertex > vertices)
 Buffer some vertices into the spritebatch.
 
void sub_buffer (const unsigned int index, std::span< Vertex > vertices)
 Sub-buffer vertex object.
 
void clear ()
 Clears out vertex buffer.
 
VertexArrayvao ()
 Get vertex array object.
 

Private Member Functions

 VertexBatch (const VertexBatch &)=delete
 Copy constructor.
 
VertexBatchoperator= (const VertexBatch &)=delete
 Copy assignment operator.
 

Private Attributes

VertexArray m_vao
 Vertex data.
 
int m_max_quads
 Maximum quads allowed.
 
int m_index
 Current index.
 

Detailed Description

Batches together vertex data to reduce draw calls.

Usually used as part of other components, like a particle engine or map system.

Definition at line 22 of file VertexBatch.hpp.

Constructor & Destructor Documentation

◆ VertexBatch() [1/3]

galaxy::graphics::VertexBatch::VertexBatch ( )

Constructor.

Definition at line 16 of file VertexBatch.cpp.

◆ VertexBatch() [2/3]

galaxy::graphics::VertexBatch::VertexBatch ( VertexBatch && s)

Move constructor.

Definition at line 22 of file VertexBatch.cpp.

◆ ~VertexBatch()

galaxy::graphics::VertexBatch::~VertexBatch ( )

Destructor.

Definition at line 41 of file VertexBatch.cpp.

◆ VertexBatch() [3/3]

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

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

VertexBatch & galaxy::graphics::VertexBatch::operator= ( VertexBatch && s)

Move assignment operator.

Definition at line 29 of file VertexBatch.cpp.

◆ init()

void galaxy::graphics::VertexBatch::init ( const int max_quads)

Initialize vertex batch data.

Parameters
max_quadsNumber of quads to allow to be batched.

Definition at line 45 of file VertexBatch.cpp.

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

◆ push()

int galaxy::graphics::VertexBatch::push ( std::span< Vertex > vertices)

Buffer some vertices into the spritebatch.

Parameters
verticesVertex data to add to spritebatch buffer.
Returns
Index where the vertx data is offset from. Useful to update animations, transforms later. -1 on error.

Definition at line 75 of file VertexBatch.cpp.

+ Here is the call graph for this function:

◆ sub_buffer()

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

Sub-buffer vertex object.

Parameters
indexOffset to start at. 0 = first vertex group (usually a group of 4 quads).
verticesVertices to assign.

Definition at line 91 of file VertexBatch.cpp.

+ Here is the call graph for this function:

◆ clear()

void galaxy::graphics::VertexBatch::clear ( )

Clears out vertex buffer.

Definition at line 96 of file VertexBatch.cpp.

+ Here is the call graph for this function:

◆ vao()

VertexArray & galaxy::graphics::VertexBatch::vao ( )
nodiscard

Get vertex array object.

Returns
Reference to VAO.

Definition at line 101 of file VertexBatch.cpp.

◆ operator=() [2/2]

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

Copy assignment operator.

Member Data Documentation

◆ m_vao

VertexArray galaxy::graphics::VertexBatch::m_vao
private

Vertex data.

Definition at line 98 of file VertexBatch.hpp.

◆ m_max_quads

int galaxy::graphics::VertexBatch::m_max_quads
private

Maximum quads allowed.

Definition at line 103 of file VertexBatch.hpp.

◆ m_index

int galaxy::graphics::VertexBatch::m_index
private

Current index.

Definition at line 108 of file VertexBatch.hpp.


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