-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuffer_tools.cpp
More file actions
31 lines (25 loc) · 820 Bytes
/
buffer_tools.cpp
File metadata and controls
31 lines (25 loc) · 820 Bytes
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
/*
Author: Lucas Parzych
OpenGL buffer object helper functions.
DR. Michael Reale wrote createBuffer (I think)
*/
void attributeBind(GLuint buffer, int index, int points)
{
glBindBuffer(GL_ARRAY_BUFFER, buffer);
glVertexAttribPointer(
index, // index of attribute array
points, // how many dimensions?
GL_FLOAT, // type
GL_FALSE, // normalized?
0, // stride
(void*)0 // array buffer offset
);
}
GLuint createBuffer(GLenum target, const void *buffer_data, GLsizei buffer_size, GLenum usageHint)
{
GLuint buffer;
glGenBuffers(1, &buffer);
glBindBuffer(target, buffer);
glBufferData(target, buffer_size, buffer_data, usageHint);
return buffer;
}