diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-11-09 11:31:28 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-11-09 11:32:25 -0500 |
commit | 354f43020d956e7f02dcc81feab13e6fa0e98e10 (patch) | |
tree | b3c6484ce799b1807e7f7b179ecfdead00f56aaa /dimension | |
parent | b79e24ded809056b3cd3a338c042d1a794bdcab3 (diff) | |
download | dimension-354f43020d956e7f02dcc81feab13e6fa0e98e10.tar.xz |
Make dmnsn_delete_scene() delete the scene's elements too.
Diffstat (limited to 'dimension')
-rw-r--r-- | dimension/main.c | 4 | ||||
-rw-r--r-- | dimension/realize.c | 22 | ||||
-rw-r--r-- | dimension/realize.h | 1 |
3 files changed, 5 insertions, 22 deletions
diff --git a/dimension/main.c b/dimension/main.c index 5d921e7..9f2ab3f 100644 --- a/dimension/main.c +++ b/dimension/main.c @@ -150,7 +150,7 @@ main(int argc, char **argv) { } if (dmnsn_raytrace_scene(scene) != 0) { - dmnsn_delete_realized_scene(scene); + dmnsn_delete_scene(scene); dmnsn_error(DMNSN_SEVERITY_HIGH, "Error rendering scene."); } @@ -166,6 +166,6 @@ main(int argc, char **argv) { } fclose(output_file); - dmnsn_delete_realized_scene(scene); + dmnsn_delete_scene(scene); return EXIT_SUCCESS; } diff --git a/dimension/realize.c b/dimension/realize.c index f9f5532..b5c4225 100644 --- a/dimension/realize.c +++ b/dimension/realize.c @@ -172,7 +172,7 @@ dmnsn_realize(const dmnsn_array *astree) /* Allocate a canvas */ scene->canvas = dmnsn_new_canvas(768, 480); if (!scene->canvas) { - dmnsn_delete_realized_scene(scene); + dmnsn_delete_scene(scene); return NULL; } @@ -198,7 +198,7 @@ dmnsn_realize(const dmnsn_array *astree) /* Create a perspective camera */ scene->camera = dmnsn_new_perspective_camera(); if (!scene->camera) { - dmnsn_delete_realized_scene(scene); + dmnsn_delete_scene(scene); return NULL; } dmnsn_set_perspective_camera_trans(scene->camera, trans); @@ -228,26 +228,10 @@ dmnsn_realize(const dmnsn_array *astree) default: fprintf(stderr, "Unrecognised syntax element '%s'.\n", dmnsn_astnode_string(astnode.type)); - dmnsn_delete_realized_scene(scene); + dmnsn_delete_scene(scene); return NULL; } } return scene; } - -void -dmnsn_delete_realized_scene(dmnsn_scene *scene) -{ - dmnsn_object *object; - unsigned int i; - - for (i = 0; i < dmnsn_array_size(scene->objects); ++i) { - dmnsn_array_get(scene->objects, i, &object); - dmnsn_delete_object(object); - } - - dmnsn_delete_camera(scene->camera); - dmnsn_delete_canvas(scene->canvas); - dmnsn_delete_scene(scene); -} diff --git a/dimension/realize.h b/dimension/realize.h index 73ea109..d6c7d51 100644 --- a/dimension/realize.h +++ b/dimension/realize.h @@ -20,4 +20,3 @@ #include "../libdimension/dimension.h" dmnsn_scene *dmnsn_realize(const dmnsn_array *astree); -void dmnsn_delete_realized_scene(dmnsn_scene *scene); |