2D_Game_Engine
Loading...
Searching...
No Matches
vertexarray.cpp
Go to the documentation of this file.
1#include <pch.hpp>
2#include <vertexarray.hpp>
3
5 glGenVertexArrays(1,&m_ID);
6 glBindVertexArray(m_ID);
7}
8
10 glDeleteVertexArrays(1,&m_ID);
11}
12
14 Bind();
15 vb.Bind();
16 unsigned int offset=0;
17 const auto &elements=layout.GetElements();
18 for(unsigned int i=0;i<elements.size();i++){
19 const auto &element=elements[i];
20 glEnableVertexAttribArray(i);
21 glVertexAttribPointer(i,element.count,element.type,element.normalized,layout.GetStride(),(const void*)offset);
22 offset+=element.count*VertexBufferElement::GetSizeOfType(element.type);
23 }
24}
25
27 const auto &elements=layout.GetElements();
28 for(unsigned int i=0;i<elements.size();i++)
29 glDisableVertexAttribArray(i);
30}
31
32void VertexArray::Bind() const{
33 glBindVertexArray(m_ID);
34}
35
37 glBindVertexArray(0);
38}
void Unbind() const
void AddBuffer(const VertexBuffer &vb, const VertexBufferLayout &layout)
void DisableAttribs(const VertexBufferLayout &layout)
void Bind() const
const std::vector< VertexBufferElement > & GetElements() const
unsigned int GetStride() const
void Bind() const
int i
static unsigned int GetSizeOfType(unsigned int type)