-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVAO.cpp
38 lines (32 loc) · 766 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
38
#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)
{
VBO.Bind();
if (type == GL_UNSIGNED_INT_2_10_10_10_REV)
glVertexAttribIPointer(layout, numComponents, type, stride, (void*)offset);
else
glVertexAttribPointer(layout, numComponents, type, GL_FALSE, stride, (void*)offset);
glEnableVertexAttribArray(layout);
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);
}