src/mesh.c

changeset 304
afe83f4642cc
parent 298
fa91e2e06eee
equal deleted inserted replaced
303:21ff357e773c 304:afe83f4642cc
32 #include <cx/allocator.h> 32 #include <cx/allocator.h>
33 33
34 #include <GL/glew.h> 34 #include <GL/glew.h>
35 35
36 int asc_mesh_allocate_buffers(AscMesh *mesh, unsigned count) { 36 int asc_mesh_allocate_buffers(AscMesh *mesh, unsigned count) {
37 asc_dprintf("Allocate mesh buffers for %u meshes.", count);
38 GLuint buffers[count]; 37 GLuint buffers[count];
39 GLuint arrays[count]; 38 GLuint arrays[count];
40 glGenBuffers(count, buffers); 39 glGenBuffers(count, buffers);
41 glGenVertexArrays(count, arrays); 40 glGenVertexArrays(count, arrays);
42 for (unsigned i = 0; i < count; i++) { 41 for (unsigned i = 0; i < count; i++) {
46 return asc_error_catch_gl("Allocating mesh buffers"); 45 return asc_error_catch_gl("Allocating mesh buffers");
47 } 46 }
48 47
49 void asc_mesh_free_buffers(AscMesh *mesh, unsigned count) { 48 void asc_mesh_free_buffers(AscMesh *mesh, unsigned count) {
50 if (count == 1 && mesh->vbo == 0) return; // hack to skip this function until we remove it 49 if (count == 1 && mesh->vbo == 0) return; // hack to skip this function until we remove it
51 asc_dprintf("Free mesh buffers for %u meshes.", count);
52 GLuint buffers[count]; 50 GLuint buffers[count];
53 GLuint arrays[count]; 51 GLuint arrays[count];
54 52
55 for (unsigned i = 0; i < count; i++) { 53 for (unsigned i = 0; i < count; i++) {
56 buffers[i] = mesh[i].vbo; 54 buffers[i] = mesh[i].vbo;

mercurial