diff options
author | 3gg <3gg@shellblade.net> | 2025-06-27 10:18:39 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-06-27 10:18:39 -0700 |
commit | bd57f345ed9dbed1d81683e48199626de2ea9044 (patch) | |
tree | 4221f2f2a7ad2244d2e93052bd68187ec91b8ea9 /src/asset/asset_cache.h | |
parent | 9a82ce0083437a4f9f58108b2c23b957d2249ad8 (diff) |
Diffstat (limited to 'src/asset/asset_cache.h')
-rw-r--r-- | src/asset/asset_cache.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/asset/asset_cache.h b/src/asset/asset_cache.h new file mode 100644 index 0000000..b2a35ed --- /dev/null +++ b/src/asset/asset_cache.h | |||
@@ -0,0 +1,37 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <gfx/sizes.h> | ||
4 | |||
5 | #include <cstring.h> | ||
6 | #include <mempool.h> | ||
7 | |||
8 | typedef struct Model Model; | ||
9 | typedef struct Texture Texture; | ||
10 | |||
11 | typedef uint64_t Hash; | ||
12 | |||
13 | typedef enum AssetType { | ||
14 | ModelAsset, | ||
15 | TextureAsset, | ||
16 | } AssetType; | ||
17 | |||
18 | typedef struct Asset { | ||
19 | AssetType type; | ||
20 | Hash hash; | ||
21 | union { | ||
22 | Model* model; | ||
23 | const Texture* texture; | ||
24 | }; | ||
25 | } Asset; | ||
26 | |||
27 | DEF_MEMPOOL(asset_pool, Asset, GFX_MAX_NUM_ASSETS) | ||
28 | |||
29 | typedef struct AssetCache { | ||
30 | asset_pool assets; | ||
31 | } AssetCache; | ||
32 | |||
33 | /// Create a new asset cache. | ||
34 | void gfx_init_asset_cache(AssetCache*); | ||
35 | |||
36 | /// Destroy the asset cache. | ||
37 | void gfx_destroy_asset_cache(AssetCache*); | ||