src/texture.c

changeset 221
14eddd43b3f7
parent 168
f70569c49c24
--- a/src/texture.c	Tue Jul 22 21:38:02 2025 +0200
+++ b/src/texture.c	Wed Jul 23 00:27:46 2025 +0200
@@ -44,7 +44,7 @@
     }
     glBindTexture(tex->target, tex->tex_id);
     glUniform1i(uniform_location, unit);
-    asc_error_catch_all_gl();
+    asc_error_catch_gl("Binding texture to uniform location");
 }
 
 void asc_texture_from_surface(AscTexture *tex, const SDL_Surface *surface) {
@@ -57,6 +57,7 @@
     glBindTexture(tex->target,tex->tex_id);
     glPixelStorei(GL_UNPACK_ROW_LENGTH,
                   surface->pitch / surface->format->BytesPerPixel);
+    if (asc_error_catch_gl("Binding texture object")) return;
 
     // Determine the format and internal format based on the SDL surface format
     GLint internal_format;
@@ -88,8 +89,7 @@
                  surface->w, surface->h,
                  0, format,
                  GL_UNSIGNED_BYTE, surface->pixels);
-    // TODO: replace catch all with proper error handling for this single call
-    asc_error_catch_all_gl();
+    asc_error_catch_gl("Writing texture data");
 }
 
 void asc_texture_from_file(AscTexture *tex, const char *name) {
@@ -131,6 +131,7 @@
 
     GLuint textures[count];
     glGenTextures(count, textures);
+    if (asc_error_catch_gl("Creating texture objects")) return;
 
     for (unsigned i = 0; i < count; ++i) {
         memset(&tex[i], 0, sizeof(AscTexture));
@@ -143,9 +144,7 @@
                         texture_filters[mag_filter]);
         asc_dprintf("Initialized texture: %u", tex[i].tex_id);
     }
-
-    // TODO: proper error handling for each gl call
-    asc_error_catch_all_gl();
+    asc_error_catch_gl("Initializing texture objects");
 }
 
 void asc_texture_destroy(AscTexture *tex, unsigned count) {

mercurial