summaryrefslogtreecommitdiff
path: root/asset.cpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-01-01 18:43:31 +1100
committerquou <quou@disroot.org>2025-01-01 18:43:31 +1100
commitd26100734623f37063206b9b144c2a29fd71d414 (patch)
tree11aefe54b4110109a841cb656b2f309ee69a1893 /asset.cpp
parent568ba73c71b650f905bd1b3f60f10871316eefdc (diff)
material system
Diffstat (limited to 'asset.cpp')
-rw-r--r--asset.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/asset.cpp b/asset.cpp
index 8a5a1cc..1d0da2c 100644
--- a/asset.cpp
+++ b/asset.cpp
@@ -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);