RunicVTT Open Source Virtual Tabletop for TTRPG using P2P
Loading...
Searching...
No Matches
VertexArray Class Reference

#include <VertexArray.h>

Collaboration diagram for VertexArray:

Public Member Functions

 VertexArray ()
 
 ~VertexArray ()
 
void AddBuffer (const VertexBuffer &vb, const VertexBufferLayout &layout)
 
void Bind () const
 
void Unbind () const
 

Private Attributes

unsigned int m_RendererID
 

Detailed Description

Definition at line 6 of file VertexArray.h.

Constructor & Destructor Documentation

◆ VertexArray()

VertexArray::VertexArray ( )

Definition at line 6 of file VertexArray.cpp.

7{
8 GLCall(glGenVertexArrays(1, &m_RendererID));
9}
#define GLCall(x)
Definition Renderer.h:12
unsigned int m_RendererID
Definition VertexArray.h:9

◆ ~VertexArray()

VertexArray::~VertexArray ( )

Definition at line 11 of file VertexArray.cpp.

12{
13 GLCall(glDeleteVertexArrays(1, &m_RendererID));
14}

Member Function Documentation

◆ AddBuffer()

void VertexArray::AddBuffer ( const VertexBuffer & vb,
const VertexBufferLayout & layout )

Definition at line 16 of file VertexArray.cpp.

17{
18 Bind();
19 vb.Bind();
20 const auto& elements = layout.GetElements();
21 unsigned int offset = 0;
22 for (unsigned int i = 0; i < elements.size(); i++)
23 {
24 const auto& element = elements[i];
25 GLCall(glEnableVertexAttribArray(i));
26 GLCall(glVertexAttribPointer(i, element.count, element.type, element.normalized, layout.GetStride(), (const void*)offset));
27 offset += element.count * VertexBufferElement::GetSizeOfType(element.type);
28 }
29}
void Bind() const
static unsigned int GetSizeOfType(unsigned int type)
Here is the call graph for this function:

◆ Bind()

void VertexArray::Bind ( ) const

Definition at line 31 of file VertexArray.cpp.

32{
33 GLCall(glBindVertexArray(m_RendererID));
34}
Here is the caller graph for this function:

◆ Unbind()

void VertexArray::Unbind ( ) const

Definition at line 36 of file VertexArray.cpp.

37{
38 GLCall(glBindVertexArray(0));
39}

Member Data Documentation

◆ m_RendererID

unsigned int VertexArray::m_RendererID
private

Definition at line 9 of file VertexArray.h.


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