summaryrefslogtreecommitdiff
path: root/gastro
diff options
context:
space:
mode:
Diffstat (limited to 'gastro')
-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) {