summaryrefslogtreecommitdiff
path: root/src/rendering.c
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2025-11-29 23:41:01 +0000
committeronelin <oscar@nelin.dk>2025-12-18 21:14:17 +0000
commit4039166875da65715e8c49d334638dc9dd1d5f7b (patch)
treea2a8e93c8e53bfd0cf52e3c4b76882585decc36e /src/rendering.c
parent4ff11620fff7d6b62e6ad57421c3ec1878aa8080 (diff)
Fix retrieving texture dimensions instead of format
Diffstat (limited to 'src/rendering.c')
-rw-r--r--src/rendering.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/rendering.c b/src/rendering.c
index 8f7104e..2c63c71 100644
--- a/src/rendering.c
+++ b/src/rendering.c
@@ -714,7 +714,7 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array,
const GladGLContext* gl = (GladGLContext*)ctx;
u32 texture_dim = BUFFERPARAMETER_TEXTURE_GET_DIMENSION(texture_parameters[0]);
- u32 texture_format = BUFFERPARAMETER_TEXTURE_GET_DIMENSION(texture_parameters[0]);
+ u32 texture_format = BUFFERPARAMETER_TEXTURE_GET_FORMAT(texture_parameters[0]);
u32 gl_texture_format;
u32 err;
@@ -736,22 +736,25 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array,
switch (texture_dim) {
case BUFFERPARAMETER_TEXTURE_1D:
gl->CreateTextures(GL_TEXTURE_1D, num_targets, texture_array);
+ ASSERT(!gl->GetError());
for (usize i = 0; i < num_targets; i++) {
- gl->TextureStorage1D(texture_array[i], 1, gl_texture_format, *texture_size[0]);
+ gl->TextureStorage1D(texture_array[i], 1, gl_texture_format, (*texture_size)[0]);
}
break;
case BUFFERPARAMETER_TEXTURE_2D:
gl->CreateTextures(GL_TEXTURE_2D, num_targets, texture_array);
+ ASSERT(!gl->GetError());
for (usize i = 0; i < num_targets; i++) {
- gl->TextureStorage2D(texture_array[i], 1, gl_texture_format, *texture_size[0], *texture_size[1]);
+ gl->TextureStorage2D(texture_array[i], 1, gl_texture_format, (*texture_size)[0], (*texture_size)[1]);
}
break;
case BUFFERPARAMETER_TEXTURE_3D:
gl->CreateTextures(GL_TEXTURE_3D, num_targets, texture_array);
+ ASSERT(!gl->GetError());
for (usize i = 0; i < num_targets; i++) {
- gl->TextureStorage3D(texture_array[i], 1, gl_texture_format, *texture_size[0], *texture_size[1], *texture_size[2]);
+ gl->TextureStorage3D(texture_array[i], 1, gl_texture_format, (*texture_size)[0], (*texture_size)[1], (*texture_size)[2]);
}
break;
@@ -766,7 +769,20 @@ void r_create_textures(void* restrict ctx, u32* restrict texture_array,
err = gl->GetError();
if (err) {
- ERROR("Failed to create textures!");
+ switch (err) {
+ case GL_INVALID_OPERATION:
+ ERROR("Failed to create textures! GL_INVALID_OPERATION");
+ break;
+ case GL_INVALID_ENUM:
+ ERROR("Failed to create textures! GL_INVALID_ENUM");
+ break;
+ case GL_INVALID_VALUE:
+ ERROR("Failed to create textures! GL_INVALID_VALUE");
+ break;
+ default:
+ ERROR("Failed to create textures!");
+ break;
+ }
}
// This should probably be changed in the future