aboutsummaryrefslogtreecommitdiff
path: root/src/scene/scene_memory.h
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-06-27 10:18:39 -0700
committer3gg <3gg@shellblade.net>2025-06-27 10:18:39 -0700
commitbd57f345ed9dbed1d81683e48199626de2ea9044 (patch)
tree4221f2f2a7ad2244d2e93052bd68187ec91b8ea9 /src/scene/scene_memory.h
parent9a82ce0083437a4f9f58108b2c23b957d2249ad8 (diff)
Restructure projectHEADmain
Diffstat (limited to 'src/scene/scene_memory.h')
-rw-r--r--src/scene/scene_memory.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/scene/scene_memory.h b/src/scene/scene_memory.h
new file mode 100644
index 0000000..d175cba
--- /dev/null
+++ b/src/scene/scene_memory.h
@@ -0,0 +1,39 @@
1/// Memory management of scene objects.
2#pragma once
3
4#include "types.h"
5
6/// Initialize scene memory.
7///
8/// The scene memory guarantees that every object maps to an index different
9/// than 0. This way, 0 can be used as a special index to denote "no value".
10void scene_mem_init();
11
12/// Destroy the scene memory and all allocated objects.
13void scene_mem_destroy();
14
15#define NAMED_INDEX(name) name##_idx
16
17#define DECL_MEMORY(name, type) \
18 typedef struct type type; \
19 /* xyz* mem_alloc_xyz() */ \
20 type* mem_alloc_##name(); \
21 /* mem_free_xyz(xyz**) */ \
22 void mem_free_##name(type**); \
23 /* xyz* mem_get_xyz(xyz_idx); */ \
24 type* mem_get_##name(NAMED_INDEX(name)); \
25 /* xyz_idx mem_get_xyz_index(const xyz*); */ \
26 NAMED_INDEX(name) mem_get_##name##_index(const type*);
27
28DECL_MEMORY(anima, Anima)
29DECL_MEMORY(animation, Animation)
30DECL_MEMORY(camera, SceneCamera)
31DECL_MEMORY(light, Light)
32DECL_MEMORY(material, Material)
33DECL_MEMORY(mesh, Mesh)
34DECL_MEMORY(mesh_link, MeshLink)
35DECL_MEMORY(model, Model)
36DECL_MEMORY(node, SceneNode)
37DECL_MEMORY(object, SceneObject)
38DECL_MEMORY(scene, Scene)
39DECL_MEMORY(skeleton, Skeleton)