-
Notifications
You must be signed in to change notification settings - Fork 0
/
VAO.cpp
37 lines (32 loc) · 780 Bytes
/
VAO.cpp
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
#include"VAO.h"
// Constructor that generates a VAO ID
VAO::VAO()
{
glGenVertexArrays(1, &ID);
}
// Links a VBO Attribute such as a position or color to the VAO
// void VAO::LinkAttrib(VBO& VBO, GLuint layout, GLuint numComponents, GLenum type, GLsizeiptr stride, void* offset)
void VAO::LinkAttrib(VBO* VBO, GLuint layout, GLuint numComponents, GLenum type, GLsizeiptr stride, void* offset)
{
// VBO.Bind();
VBO->Bind();
glVertexAttribPointer(layout, numComponents, type, GL_FALSE, stride, offset);
glEnableVertexAttribArray(layout);
// VBO.Unbind();
VBO->Unbind();
}
// Binds the VAO
void VAO::Bind()
{
glBindVertexArray(ID);
}
// Unbinds the VAO
void VAO::Unbind()
{
glBindVertexArray(0);
}
// Deletes the VAO
void VAO::Delete()
{
glDeleteVertexArrays(1, &ID);
}