aboutsummaryrefslogtreecommitdiff
path: root/src/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/memory.c')
-rw-r--r--src/memory.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/memory.c b/src/memory.c
index a68bc2b..3481791 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -1,21 +1,22 @@
1#include "memory.h" 1#include "memory.h"
2 2
3#include <gfx/scene/camera.h>
3#include <gfx/sizes.h> 4#include <gfx/sizes.h>
4 5
5#include "render/llr_impl.h" 6#include "render/llr_impl.h"
6#include "scene/animation_impl.h" 7#include "scene/animation_impl.h"
7#include "scene/camera_impl.h"
8#include "scene/model_impl.h" 8#include "scene/model_impl.h"
9#include "scene/node_impl.h" 9#include "scene/node_impl.h"
10#include "scene/object_impl.h" 10#include "scene/object_impl.h"
11#include "scene/scene_impl.h" 11#include "scene/scene_impl.h"
12 12
13#include <log/log.h> 13#include <log/log.h>
14#include <math/camera.h>
14#include <mempool.h> 15#include <mempool.h>
15 16
16DEF_MEMPOOL(anima_pool, Anima, GFX_MAX_NUM_ANIMAS) 17DEF_MEMPOOL(anima_pool, Anima, GFX_MAX_NUM_ANIMAS)
17DEF_MEMPOOL(animation_pool, Animation, GFX_MAX_NUM_ANIMATIONS) 18DEF_MEMPOOL(animation_pool, Animation, GFX_MAX_NUM_ANIMATIONS)
18DEF_MEMPOOL(camera_pool, SceneCamera, GFX_MAX_NUM_CAMERAS) 19DEF_MEMPOOL(camera_pool, Camera, GFX_MAX_NUM_CAMERAS)
19DEF_MEMPOOL(light_pool, Light, GFX_MAX_NUM_LIGHTS) 20DEF_MEMPOOL(light_pool, Light, GFX_MAX_NUM_LIGHTS)
20DEF_MEMPOOL(material_pool, Material, GFX_MAX_NUM_MATERIALS) 21DEF_MEMPOOL(material_pool, Material, GFX_MAX_NUM_MATERIALS)
21DEF_MEMPOOL(mesh_pool, Mesh, GFX_MAX_NUM_MESHES) 22DEF_MEMPOOL(mesh_pool, Mesh, GFX_MAX_NUM_MESHES)
@@ -56,7 +57,7 @@ static SceneMemory mem;
56#define PLURAL(name) name##s 57#define PLURAL(name) name##s
57#define MEM_FIELD(name) mem.PLURAL(name) 58#define MEM_FIELD(name) mem.PLURAL(name)
58 59
59void scene_mem_init() { 60void scene_mem_init(void) {
60 mempool_make(&mem.animas); 61 mempool_make(&mem.animas);
61 mempool_make(&mem.animations); 62 mempool_make(&mem.animations);
62 mempool_make(&mem.cameras); 63 mempool_make(&mem.cameras);
@@ -86,7 +87,7 @@ void scene_mem_init() {
86 ALLOC_DUMMY(&mem.skeletons); 87 ALLOC_DUMMY(&mem.skeletons);
87} 88}
88 89
89void scene_mem_destroy() { 90void scene_mem_destroy(void) {
90 // NOTE: the dummy objects are not constructed, so the destruction code below 91 // NOTE: the dummy objects are not constructed, so the destruction code below
91 // always skips index 0. (I don't really like the conditional inside the loop, 92 // always skips index 0. (I don't really like the conditional inside the loop,
92 // but this gets the job done without having to specialize the loop macro.) 93 // but this gets the job done without having to specialize the loop macro.)
@@ -148,7 +149,7 @@ void scene_mem_destroy() {
148 149
149#define DEF_MEMORY(NAME, TYPE) \ 150#define DEF_MEMORY(NAME, TYPE) \
150 /* xyz* mem_alloc_xyz(); */ \ 151 /* xyz* mem_alloc_xyz(); */ \
151 TYPE* mem_alloc_##NAME() { return mempool_alloc(&MEM_FIELD(NAME)); } \ 152 TYPE* mem_alloc_##NAME(void) { return mempool_alloc(&MEM_FIELD(NAME)); } \
152 /* void mem_free_xyz(xyz**); */ \ 153 /* void mem_free_xyz(xyz**); */ \
153 void mem_free_##NAME(TYPE** obj) { mempool_free(&MEM_FIELD(NAME), obj); } \ 154 void mem_free_##NAME(TYPE** obj) { mempool_free(&MEM_FIELD(NAME), obj); } \
154 /* xyz* mem_get_xyz(xyz_idx); */ \ 155 /* xyz* mem_get_xyz(xyz_idx); */ \
@@ -164,7 +165,7 @@ void scene_mem_destroy() {
164 165
165DEF_MEMORY(anima, Anima) 166DEF_MEMORY(anima, Anima)
166DEF_MEMORY(animation, Animation) 167DEF_MEMORY(animation, Animation)
167DEF_MEMORY(camera, SceneCamera) 168DEF_MEMORY(camera, Camera)
168DEF_MEMORY(light, Light) 169DEF_MEMORY(light, Light)
169DEF_MEMORY(material, Material) 170DEF_MEMORY(material, Material)
170DEF_MEMORY(mesh, Mesh) 171DEF_MEMORY(mesh, Mesh)