diff options
author | BoredGuy <osome3717@gmail.com> | 2025-07-30 23:33:22 +0300 |
---|---|---|
committer | BoredGuy <osome3717@gmail.com> | 2025-07-30 23:33:22 +0300 |
commit | c05e188ef6a4b715848f9f0b401351a43c80168d (patch) | |
tree | dc1dd17a8623b26bac9bc6b959084babe556ee32 /src/assets.c | |
parent | 815aec62f8ae3a403e913559d5fe6138c8825007 (diff) |
Small Refactor
Diffstat (limited to 'src/assets.c')
-rw-r--r-- | src/assets.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/src/assets.c b/src/assets.c index 8edfde6..073c748 100644 --- a/src/assets.c +++ b/src/assets.c @@ -4,18 +4,6 @@ #include <stdint.h> #include "assets.h" -typedef enum AssetType { - Texture_Asset -} AssetType; - -typedef struct Asset { - AssetType type; - const char* name; - const char* filePath; - - Texture2D texture; -} Asset; - Asset assets[] = { { .type = Texture_Asset, @@ -37,9 +25,12 @@ void LoadAssets() { Asset* c = &assets[i]; switch (c->type) { - case Texture_Asset: - c->texture = LoadTexture(c->filePath); - break; + case Texture_Asset: + c->texture = LoadTexture(c->filePath); + break; + + default: + break; } } } @@ -52,16 +43,21 @@ Asset* GetMatchingAssetWithType(const char* targetName, AssetType targetType) { return c; } - return NULL; + printf("Failed to load asset with name: %s, exitting!\n", targetName); + exit(EXIT_FAILURE); } -Texture2D GetTexture(const char* name) { - Asset* textureAsset = GetMatchingAssetWithType(name, Texture_Asset); +void UnloadAssets() { + for (size_t i = 0; i < ASSET_COUNT; i++) { + Asset* c = &assets[i]; + + switch (c->type) { + case Texture_Asset: + UnloadTexture(c->texture); + break; - if (textureAsset == NULL) { - fprintf(stderr, "Failed to load texture with name: %s, exitting!\n", name); - exit(EXIT_FAILURE); + default: + break; + } } - - return textureAsset->texture; } |