summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
new file mode 100644
index 0000000..0a5d983
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,24 @@
+#include "util.h"
+
+void create_vbo(GLuint *vbo, void* buf, int size) {
+ //tell opengl we want mem for 1 buffer object
+ glGenBuffers(1, vbo);
+ // set aray_buffer to above
+ glBindBuffer(GL_ARRAY_BUFFER, *vbo);
+ // copy vertex data to gpu memory
+ glBufferData(GL_ARRAY_BUFFER, size, buf, GL_STATIC_DRAW);
+ // cleanup
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+}
+
+void create_ebo(GLuint *ebo, void* buf, int size) {
+ //tell opengl we want mem for 1 buffer object
+ glGenBuffers(1, ebo);
+ // set aray_buffer to above
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, *ebo);
+ // copy vertex data to gpu memory
+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, buf, GL_STATIC_DRAW);
+ // cleanup
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+}
+