src/mesh.c

changeset 221
14eddd43b3f7
parent 220
6b266e907f89
--- a/src/mesh.c	Tue Jul 22 21:38:02 2025 +0200
+++ b/src/mesh.c	Wed Jul 23 00:27:46 2025 +0200
@@ -42,7 +42,7 @@
         mesh[i].vbo = buffers[i];
         mesh[i].vao = arrays[i];
     }
-    return asc_error_catch_all_gl();
+    return asc_error_catch_gl("Allocating mesh buffers");
 }
 
 void asc_mesh_free_buffers(AscMesh *mesh, unsigned count) {
@@ -58,15 +58,16 @@
         mesh[i].vao = 0;
     }
 
+    asc_error_catch_gl("OpenGL has unchecked error flags before deleting mesh buffers");
     glDeleteBuffers(count, buffers);
     glDeleteVertexArrays(count, arrays);
-    asc_error_catch_all_gl();
+    asc_error_catch_gl("Deleting mesh buffers");
 }
 
 void asc_mesh_draw_triangle_strip(const AscMesh *mesh) {
     glBindVertexArray(mesh->vao);
     glDrawArrays(GL_TRIANGLE_STRIP, 0, mesh->vtx_count);
-    asc_error_catch_all_gl();
+    asc_error_catch_gl("Drawing mesh");
 #ifndef NDEBUG
     // only unbind in debug mode to detect accidental re-use of the wrong VAO
     glBindVertexArray(0);
@@ -92,6 +93,7 @@
         // only bind the buffer for updating the data
         glBindBuffer(GL_ARRAY_BUFFER, mesh->vbo);
     }
+    if (asc_error_catch_gl("Binding VBO or VAO")) return;
 
     unsigned required_memory = 4 * sizeof(asc_vertex2d);
 
@@ -132,7 +134,5 @@
     data[3].pos = ASC_VEC2F(args.size.x, args.size.y);
     data[3].uv = ASC_VEC2F(args.uv_offset.x + args.uv_scale.x, args.uv_offset.y + args.uv_scale.y);
     glBufferData(GL_ARRAY_BUFFER, mesh->vtx_data_size, mesh->vtx_data, GL_STATIC_DRAW);
-
-    // TODO: replace with specific error handling for setting the buffer
-    asc_error_catch_all_gl();
+    asc_error_catch_gl("Writing VBO data");
 }

mercurial