-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertexArray.hpp
More file actions
48 lines (35 loc) · 1.23 KB
/
Copy pathVertexArray.hpp
File metadata and controls
48 lines (35 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <glad/glad.h>
#include <utility>
#include <span>
#include "VertexBuffer.hpp"
class VertexArray {
private:
GLuint id;
public:
VertexArray(){
glGenVertexArrays(1, &id);
}
~VertexArray(){
if(id !=0){
glDeleteVertexArrays(1, &id);
}
}
void bind(){
glBindVertexArray(id);
}
void unbind(){
glBindVertexArray(0);
}
void addAtributte(VertexBuffer &vertexBuffer, int index, int size, GLenum type, GLboolean normalized, int divisor){
bind();
glEnableVertexAttribArray(index);
vertexBuffer.bind();
//for now 0 because we let the controller calculate the stride cause our data array are homogeneos
//for now nullptr because we have separated buffers for each attribute
glVertexAttribPointer(index, size, type, normalized, 0 ,nullptr);
// Tells the gpu the size of the steps as it reads the vbos,
// we want to read an element at a time for the changing attibs and not move for the base geometry
glVertexAttribDivisor(index, divisor);
}
};