summaryrefslogtreecommitdiff
path: root/src/assets.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/assets.c')
-rw-r--r--src/assets.c42
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;
}