-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathEBO.cpp
More file actions
77 lines (57 loc) · 1.72 KB
/
Copy pathEBO.cpp
File metadata and controls
77 lines (57 loc) · 1.72 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "EBO.hpp"
// Constructor that generates an
// Elements Buffer Object and links it to indices
EBO::EBO(GLuint* indices, GLsizeiptr size)
{
// Generate a reference ID for the EBO
glGenBuffers(1, &ID);
// Bind the EBO with the ID we created
// to the element array buffer OpenGL
// uses for EBOs
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
// Put the indices data into the EBO buffer
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indices, GL_STATIC_DRAW);
}
// Constructor that generates an
// Elements Buffer Object and does not link it to indices
EBO::EBO(GLsizeiptr size)
{
// Generate a reference ID for the EBO
glGenBuffers(1, &ID);
// Bind the EBO with the ID we created
// to the element array buffer OpenGL
// uses for EBOs
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
// Put the indices data into the EBO buffer
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, nullptr, GL_STATIC_DRAW);
}
// Binds the EBO
void EBO::Bind()
{
// Bind the EBO again when needed
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
}
// Unbinds the EBO
void EBO::Unbind()
{
// Unbind the EBO when needed
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
// Deletes the EBO
void EBO::Delete()
{
// Delete the EBO
glDeleteBuffers(1, &ID);
}
// Initialize the EBO from blank constructor
void EBO::InitEBO(GLuint* indices, GLsizeiptr size)
{
// Generate a reference ID for the EBO
glGenBuffers(1, &ID);
// Bind the EBO with the ID we created
// to the element array buffer OpenGL
// uses for EBOs
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ID);
// Put the indices data into the EBO buffer
glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indices, GL_STATIC_DRAW);
}