diff options
author | quou <quou@disroot.org> | 2025-01-01 18:43:31 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2025-01-01 18:43:31 +1100 |
commit | d26100734623f37063206b9b144c2a29fd71d414 (patch) | |
tree | 11aefe54b4110109a841cb656b2f309ee69a1893 /asset.cpp | |
parent | 568ba73c71b650f905bd1b3f60f10871316eefdc (diff) |
material system
Diffstat (limited to 'asset.cpp')
-rw-r--r-- | asset.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -8,7 +8,7 @@ extern "C" { } #define max_asset_types 32 -#define asset_scratch_size (1024 * 1024) +#define asset_scratch_size (1024) struct RLoader { char magic[4]; @@ -75,12 +75,6 @@ void Asset_Arena::init( p = pack_open(pack_name, arena); assert(p != 0); a = arena; - s = (Arena*)arena_alloc(a, sizeof *s); - init_arena( - s, - arena_alloc(a, asset_scratch_size), - asset_scratch_size - ); max_assets = max; assets = (Bucket*)arena_alloc(arena, max * sizeof(Bucket)); for (i = 0; i < max; i++) @@ -112,6 +106,8 @@ int Asset_Arena::bucket(const char* name) { Asset* Asset_Arena::load(const char* name) { char magic[4]; + char scratch[asset_scratch_size]; + Arena sa; Pack_File* f; int b = bucket(name); assert(b >= 0); @@ -122,8 +118,8 @@ Asset* Asset_Arena::load(const char* name) { pack_read(f, magic, 4); pack_seek(f, 0, seek_rel_start); Asset_Loader& loader = manager.get_loader(magic); - clear_arena(s); - Asset* asset = loader.load(a, s, name, f); + init_arena(&sa, scratch, sizeof scratch); + Asset* asset = loader.load(a, &sa, name, f); if (asset) { asset->loader = &loader; assets[b].name = dup_string(a, name); |