diff options
author | kdx <kikoodx@paranoici.org> | 2023-03-25 04:45:24 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-03-25 04:45:38 +0100 |
commit | 9506c24b9303d4a476e31711ad854cee006f3169 (patch) | |
tree | 19f2f87bb7444ccfa82535781106b65de5ad2617 /main.c | |
parent | 7dd6658d452fe8e447205cfc34594a537221b9a1 (diff) | |
download | tzr-9506c24b9303d4a476e31711ad854cee006f3169.tar.gz |
bump to C23
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 33 |
1 files changed, 20 insertions, 13 deletions
@@ -1,4 +1,4 @@ -/* gcc TZR.c main.c -lSDL2 */ +/* gcc -std=c2x TZR.c main.c -lSDL2 -lSDL2_image */ #include "TZR.h" @@ -10,14 +10,20 @@ int main(int argc, char **argv) if (TZR_Init(.width=256, .height=256, .pixel_perfect=false)) return 1; + /* Call TZR_Quit on exit. */ + if (atexit(TZR_Quit)) { + perror("atexit(TZR_Quit)"); + return 1; + } + /* Load assets. */ const TZR_Uint id0 = TZR_LoadResourceTyped(TZR_RES_IMAGE, "res.bmp"); const TZR_Uint id1 = TZR_LoadResourceTyped(TZR_RES_RAW, "main.c"); - TZR_LoadResourceTyped(TZR_RES_IMAGE, "res.bmp"); - TZR_LoadResourceTyped(TZR_RES_RAW, "main.c"); + (void)TZR_LoadResourceTyped(TZR_RES_IMAGE, "res.bmp"); + (void)TZR_LoadResourceTyped(TZR_RES_RAW, "main.c"); const TZR_Uint id2 = TZR_LoadResource("smile.bmp"); if (id0 != 1 || id1 != 2 || id2 != 3) - return TZR_Quit(), 1; + return 1; /* Asset loading w/ #embed (C23 proposal). */ /* static const char res_bmp[] = @@ -38,14 +44,15 @@ int main(int argc, char **argv) x += TZR_IsKeyDown(SDL_SCANCODE_RIGHT); y -= TZR_IsKeyDown(SDL_SCANCODE_UP); y += TZR_IsKeyDown(SDL_SCANCODE_DOWN); - TZR_DrawBegin(); - TZR_DrawSetColor(0.0f, 0.0f, 0.0f); - TZR_DrawClear(); - TZR_DrawSetColor(1.0f, 1.0f, 1.0f, 0.2f); - TZR_DrawImage(id0, 128+x, 128+y, .sy=(float)x/10, .center=true); - TZR_DrawSetColor(.a=0.5f); - TZR_DrawImage(id2, y, x, .w=x*2); - TZR_DrawEnd(); + if (TZR_DrawBegin() + || TZR_DrawSetColor(0.0f, 0.0f, 0.0f) + || TZR_DrawClear() + || TZR_DrawSetColor(1.0f, 1.0f, 1.0f, 0.2f) + || TZR_DrawImage(id0, 128+x, 128+y, .sy=(float)x/10, .center=true) + || TZR_DrawSetColor(.a=0.5f) + || TZR_DrawImage(id2, y, x, .w=x*2) + || TZR_DrawEnd()) + return 1; } - return TZR_Quit(), 0; + return 0; } |