summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-08-28 20:54:07 -0400
committerLLLL Colonq <llll@colonq>2026-08-28 20:54:07 -0400
commitdfe15a250a89a7ec46b65608f78d161d0cf4b183 (patch)
treefe499ea1c09ba9c97cc0b404e24dfb4f9e359dc7
parent8567564e6df6efbcf138b390ba181b8ebb118fa1 (diff)
gastro: Fail more gracefully in test scene
-rw-r--r--gastro/src/test.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/gastro/src/test.c b/gastro/src/test.c
index 46ce6b1..269ac9e 100644
--- a/gastro/src/test.c
+++ b/gastro/src/test.c
@@ -157,7 +157,7 @@ static gastro_color fragment_shader_teapot(gastro_ctx *ctx, gastro_vec3 in, gast
return gastro_color_new(0xff - col, 0xff - col, 0xff - col, 0xff);
}
-static void load_image(char *path) {
+static bool load_image(char *path) {
FILE *f;
u8 *buf;
i64 len;
@@ -166,7 +166,7 @@ static void load_image(char *path) {
qoi_color *pixels;
if (!(f = fopen(path, "r"))) {
fprintf(stderr, "failed to open file: %s\n", path);
- return;
+ return false;
}
fseek(f, 0, SEEK_END);
len = ftell(f);
@@ -176,19 +176,21 @@ static void load_image(char *path) {
qoi_decoder_new(&q, buf, len);
if (!qoi_decode_header(&q, &h)) {
fprintf(stderr, "failed to decode header\n");
- return;
+ return false;
}
pixels = calloc(h.width * h.height, sizeof(qoi_color));
qoi_decode(&q, &h, pixels);
texture = pixels;
texture_width = h.width;
texture_height = h.height;
+ return true;
}
bool gastro_test_create() {
program.vertex = vertex_shader;
program.fragment = fragment_shader_texture;
- load_image("test.qoi");
+ if (!load_image("test.qoi")) return false;
+ return true;
}
void gastro_test_render(gastro_ctx *ctx) {