diff options
Diffstat (limited to 'dc/dc.c')
| -rw-r--r-- | dc/dc.c | 33 |
1 files changed, 12 insertions, 21 deletions
@@ -4,6 +4,9 @@ #include <math.h> #include <unistd.h> +#define QOI_IMPLEMENTATION +#include "third/qoi.h" + #define SCREEN_WIDTH 256 #define SCREEN_HEIGHT 256 @@ -19,37 +22,25 @@ int main(void) }; ty_init(hints); -#define Y TY_COLOR_YELLOW -#define B TY_COLOR_BLACK -#define M TY_COLOR_MAGENTA - struct ty_color img_data[] = { - M, Y, Y, Y, Y, M, - Y, Y, Y, Y, Y, Y, - Y, B, Y, Y, B, Y, - Y, Y, Y, Y, Y, Y, - Y, B, B, B, B, Y, - M, Y, Y, Y, Y, M, - }; -#undef Y -#undef B -#undef M - - struct ty_image img = ty_create_image(6, 6, img_data); + qoi_desc desc; + void *data = qoi_read("test_img.qoi", &desc, 3); + if (!data) + ty_log_fatal(TY_ERR_IO, "Failed to read image"); + struct ty_image img = ty_create_image(desc.width, desc.height, data); + free(data); while (ty_is_game_running()) { ty_draw_clear(TY_COLOR_BLACK); - ty_draw_image(img, ty_vec2i(200, 200)); - ty_draw_image_ex( img, (struct ty_recti){ 0, 0, - 6, 6, + img.width, img.height, }, (struct ty_recti){ - 100, 200, - img.width*12, img.height*6, + 0, 0, + SCREEN_WIDTH, SCREEN_HEIGHT, } ); |
