From 58245585cbe77e6c03ebe13f29e10393ff3c45b4 Mon Sep 17 00:00:00 2001 From: quou Date: Sun, 22 Dec 2024 22:19:36 +1100 Subject: cute asset loading system --- asset.hpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 asset.hpp (limited to 'asset.hpp') diff --git a/asset.hpp b/asset.hpp new file mode 100644 index 0000000..27ac990 --- /dev/null +++ b/asset.hpp @@ -0,0 +1,41 @@ +#ifndef asset_hpp +#define asset_hpp + +struct Arena; +struct Asset_Loader; +struct Pack_File; +struct Pack; + +struct Asset { + Asset* next; + Asset_Loader* loader; + virtual bool load( + Asset_Loader* loader, + Arena* a, + Pack_File* f + ) = 0; + virtual void unload(Asset_Loader* loader) = 0; +}; + +struct Asset_Loader { + virtual Asset* load(Arena* a, Pack_File* f) = 0; +}; + +struct Asset_Arena { + Pack* p; + Arena* a; + Asset* assets; + + void init(Arena* arena, const char* pack_name); + void destroy(); + + Asset* load(const char* name); + void claim(Asset* a); +}; + +void register_asset_loader( + const char* magic, + Asset_Loader* loader +); + +#endif -- cgit v1.2.3-54-g00ecf