diff options
Diffstat (limited to 'src/memory.c')
| -rw-r--r-- | src/memory.c | 13 | 
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 | ||
| 16 | DEF_MEMPOOL(anima_pool, Anima, GFX_MAX_NUM_ANIMAS) | 17 | DEF_MEMPOOL(anima_pool, Anima, GFX_MAX_NUM_ANIMAS) | 
| 17 | DEF_MEMPOOL(animation_pool, Animation, GFX_MAX_NUM_ANIMATIONS) | 18 | DEF_MEMPOOL(animation_pool, Animation, GFX_MAX_NUM_ANIMATIONS) | 
| 18 | DEF_MEMPOOL(camera_pool, SceneCamera, GFX_MAX_NUM_CAMERAS) | 19 | DEF_MEMPOOL(camera_pool, Camera, GFX_MAX_NUM_CAMERAS) | 
| 19 | DEF_MEMPOOL(light_pool, Light, GFX_MAX_NUM_LIGHTS) | 20 | DEF_MEMPOOL(light_pool, Light, GFX_MAX_NUM_LIGHTS) | 
| 20 | DEF_MEMPOOL(material_pool, Material, GFX_MAX_NUM_MATERIALS) | 21 | DEF_MEMPOOL(material_pool, Material, GFX_MAX_NUM_MATERIALS) | 
| 21 | DEF_MEMPOOL(mesh_pool, Mesh, GFX_MAX_NUM_MESHES) | 22 | DEF_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 | ||
| 59 | void scene_mem_init() { | 60 | void 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 | ||
| 89 | void scene_mem_destroy() { | 90 | void 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 | ||
| 165 | DEF_MEMORY(anima, Anima) | 166 | DEF_MEMORY(anima, Anima) | 
| 166 | DEF_MEMORY(animation, Animation) | 167 | DEF_MEMORY(animation, Animation) | 
| 167 | DEF_MEMORY(camera, SceneCamera) | 168 | DEF_MEMORY(camera, Camera) | 
| 168 | DEF_MEMORY(light, Light) | 169 | DEF_MEMORY(light, Light) | 
| 169 | DEF_MEMORY(material, Material) | 170 | DEF_MEMORY(material, Material) | 
| 170 | DEF_MEMORY(mesh, Mesh) | 171 | DEF_MEMORY(mesh, Mesh) | 
