-
Notifications
You must be signed in to change notification settings - Fork 0
/
buffer.c
49 lines (43 loc) · 1 KB
/
buffer.c
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
#include <stdio.h>
#include <string.h>
#include <glisy/gl.h>
#include <glisy/buffer.h>
void
glisyBufferInit(GlisyBuffer *buffer, GLuint target) {
if (!buffer) return;
if (target == 0) target = GL_ARRAY_BUFFER;
buffer->handle = 0;
buffer->target = target;
}
void
glisyBufferBind(GlisyBuffer *buffer) {
if (!buffer) return;
glGenBuffers(1, &buffer->handle);
glBindBuffer(buffer->target, buffer->handle);
}
void
glisyBufferUnbind(GlisyBuffer *buffer) {
if (!buffer) return;
glBindBuffer(buffer->target, 0);
}
void
glisyBufferDispose(GlisyBuffer *buffer) {
if (!buffer) return;
glDeleteBuffers(1, &buffer->handle);
buffer->handle = 0;
}
void
glisyBufferUpdate(GlisyBuffer *buffer, GLuint usage) {
if (!buffer) return;
glBufferData(buffer->target,
buffer->size,
buffer->data,
usage);
}
void
glisyBufferSource(GlisyBuffer *buffer, GLsizei size, GLvoid *data) {
if (!buffer) return;
if (!data) return;
buffer->size = size;
buffer->data = data;
}