diff options
author | kdx <kikoodx@paranoici.org> | 2023-03-26 22:38:18 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-03-26 22:38:24 +0200 |
commit | eb741d4dc4fbd9f2ad0fbd0193df7d1fceb35c94 (patch) | |
tree | 66b7b24b7b4cb15e69fb0a3da47b930bc4bbb67c | |
parent | 56e36261a6c2c9fe1a5291cddeb739a18740bbad (diff) | |
download | tzr-eb741d4dc4fbd9f2ad0fbd0193df7d1fceb35c94.tar.gz |
tzr style resource usage
-rw-r--r-- | headers/TZR_resource.h | 2 | ||||
-rw-r--r-- | sources/TZR_DrawImage.c | 5 | ||||
-rw-r--r-- | sources/TZR_LoadResourceTyped.c | 2 |
3 files changed, 8 insertions, 1 deletions
diff --git a/headers/TZR_resource.h b/headers/TZR_resource.h index 06f0763..87373f0 100644 --- a/headers/TZR_resource.h +++ b/headers/TZR_resource.h @@ -1,6 +1,8 @@ #pragma once #include "TZR_types.h" +#define TZR_RES TZR_LoadResource + /* Return 0 on error. */ [[nodiscard]] TZR_Uint TZR_LoadResourceFromMemory(TZR_ResourceType type, const void *data, int size); diff --git a/sources/TZR_DrawImage.c b/sources/TZR_DrawImage.c index 862d94c..b9b4606 100644 --- a/sources/TZR_DrawImage.c +++ b/sources/TZR_DrawImage.c @@ -9,6 +9,11 @@ int _TZR_DrawImage(const TZR_DrawImageArgs *args) { + if (args->id == 0) { + fprintf(stderr, "args->id is 0\n"); + return -1; + } + if (TZR_GetResourceType(args->id) != TZR_RES_IMAGE) { fprintf(stderr, "%u isn't an image\n", args->id); return -1; diff --git a/sources/TZR_LoadResourceTyped.c b/sources/TZR_LoadResourceTyped.c index 3c38ee2..126737b 100644 --- a/sources/TZR_LoadResourceTyped.c +++ b/sources/TZR_LoadResourceTyped.c @@ -10,7 +10,7 @@ TZR_LoadResourceTyped(TZR_ResourceType type, const char *path) for (TZR_Uint i = 0; i < ___tzr_resources_size; i++) if (___tzr_resources[i].type == type && strcmp(___tzr_resources[i].path, path) == 0) - return i; + return i + 1; FILE *const fp = fopen(path, "rb"); if (fp == NULL) { perror(path); |