RunicVTT Open Source Virtual Tabletop for TTRPG using P2P
Loading...
Searching...
No Matches
VertexArray.cpp
Go to the documentation of this file.
1#pragma once
2#include "VertexArray.h"
3#include "Renderer.h"
5
7{
8 GLCall(glGenVertexArrays(1, &m_RendererID));
9}
10
12{
13 GLCall(glDeleteVertexArrays(1, &m_RendererID));
14}
15
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}
30
32{
33 GLCall(glBindVertexArray(m_RendererID));
34}
35
37{
38 GLCall(glBindVertexArray(0));
39}
#define GLCall(x)
Definition Renderer.h:12
void Unbind() const
unsigned int m_RendererID
Definition VertexArray.h:9
void AddBuffer(const VertexBuffer &vb, const VertexBufferLayout &layout)
void Bind() const
static unsigned int GetSizeOfType(unsigned int type)