27 |
27 |
28 #include "ascension/mesh.h" |
28 #include "ascension/mesh.h" |
29 #include "ascension/error.h" |
29 #include "ascension/error.h" |
30 |
30 |
31 #include <GL/glew.h> |
31 #include <GL/glew.h> |
|
32 #include <assert.h> |
32 |
33 |
33 void asc_mesh_allocate_buffers(AscMesh *mesh, unsigned count) { |
34 void asc_mesh_allocate_buffers(AscMesh *mesh, unsigned count) { |
34 asc_dprintf("Allocate mesh buffers for %u meshes.", count); |
35 asc_dprintf("Allocate mesh buffers for %u meshes.", count); |
35 GLuint buffers[count]; |
36 GLuint buffers[count]; |
36 GLuint arrays[count]; |
37 GLuint arrays[count]; |
43 asc_error_catch_all_gl(); |
44 asc_error_catch_all_gl(); |
44 } |
45 } |
45 |
46 |
46 void asc_mesh_free_buffers(AscMesh *mesh, unsigned count) { |
47 void asc_mesh_free_buffers(AscMesh *mesh, unsigned count) { |
47 asc_dprintf("Free mesh buffers for %u meshes.", count); |
48 asc_dprintf("Free mesh buffers for %u meshes.", count); |
48 if (count > 32) { |
|
49 asc_error("Trying to free more than 32 mesh buffers at once."); |
|
50 count = 32; |
|
51 } |
|
52 GLuint buffers[count]; |
49 GLuint buffers[count]; |
53 GLuint arrays[count]; |
50 GLuint arrays[count]; |
54 |
51 |
55 for (unsigned i = 0; i < count; i++) { |
52 for (unsigned i = 0; i < count; i++) { |
56 buffers[i] = mesh[i].vbo; |
53 buffers[i] = mesh[i].vbo; |