src/texture.c

changeset 92
78ce93fb46e5
parent 91
8433c87c0f51
--- a/src/texture.c	Tue Apr 22 19:36:27 2025 +0200
+++ b/src/texture.c	Wed Apr 23 23:43:45 2025 +0200
@@ -39,7 +39,9 @@
     glActiveTexture(GL_TEXTURE0 + unit);
     GLenum error = glGetError();
     if (error == GL_INVALID_ENUM) {
-        asc_error("Tried to use more texture units than available.");
+        GLint max_units;
+        glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &max_units);
+        asc_error("Tried to use more texture units than available (%u/%u).", unit, max_units);
     }
     glBindTexture(tex->target, tex->tex_id);
     glUniform1i(uniform_location, unit);
@@ -48,8 +50,7 @@
 
 void asc_texture_from_surface(AscTexture *tex, SDL_Surface const *surface) {
     if (tex->tex_id == 0) {
-        asc_error("Tried to use uninitialized texture.");
-        asc_dprintf("Texture address: %"PRIxPTR, (uintptr_t) tex);
+        asc_error("Tried to use uninitialized texture (%"PRIxPTR ").", (uintptr_t) tex);
         return;
     }
     tex->width = surface->w;
@@ -81,8 +82,7 @@
             format = GL_BGRA;
             break;
         default:
-            // TODO: add more output once asc_error allows format strings
-            asc_error("Unsupported pixel format.");
+            asc_error("Unsupported pixel format: %x", surface->format->format);
             return;
     }
     glTexImage2D(tex->target, 0, internal_format,
@@ -153,8 +153,7 @@
     GLuint textures[count];
     for (unsigned i = 0; i < count; ++i) {
         if (tex[i].refcount > 0) {
-            // TODO: asc_wprintf() for warnings
-            asc_dprintf("Texture %u still in use by %u objects.",
+            asc_wprintf("Texture %u still in use by %u objects.",
                 tex[i].tex_id, tex[i].refcount);
         }
         asc_dprintf("Destroy texture: %u", tex[i].tex_id);

mercurial