summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-11-09 11:31:28 -0500
committerTavian Barnes <tavianator@gmail.com>2009-11-09 11:32:25 -0500
commit354f43020d956e7f02dcc81feab13e6fa0e98e10 (patch)
treeb3c6484ce799b1807e7f7b179ecfdead00f56aaa /tests
parentb79e24ded809056b3cd3a338c042d1a794bdcab3 (diff)
downloaddimension-354f43020d956e7f02dcc81feab13e6fa0e98e10.tar.xz
Make dmnsn_delete_scene() delete the scene's elements too.
Diffstat (limited to 'tests')
-rw-r--r--tests/libdimension/gl.c18
-rw-r--r--tests/libdimension/png.c10
-rw-r--r--tests/libdimension/tests.c34
-rw-r--r--tests/libdimension/tests.h1
4 files changed, 22 insertions, 41 deletions
diff --git a/tests/libdimension/gl.c b/tests/libdimension/gl.c
index 83648cd..7e45c3b 100644
--- a/tests/libdimension/gl.c
+++ b/tests/libdimension/gl.c
@@ -40,7 +40,7 @@ main() {
/* Optimize the canvas for GL drawing */
if (dmnsn_gl_optimize_canvas(scene->canvas) != 0) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Couldn't optimize canvas for GL! ---\n");
return EXIT_FAILURE;
}
@@ -48,7 +48,7 @@ main() {
/* Create a new glX display */
display = dmnsn_new_display(scene->canvas);
if (!display) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Couldn't initialize X or glX! ---\n");
return EXIT_FAILURE;
}
@@ -59,7 +59,7 @@ main() {
progress = dmnsn_raytrace_scene_async(scene);
if (!progress) {
dmnsn_delete_display(display);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Couldn't start raytracing worker thread! ---\n");
return EXIT_FAILURE;
}
@@ -68,7 +68,7 @@ main() {
while (dmnsn_get_progress(progress) < 1.0) {
if (dmnsn_gl_write_canvas(scene->canvas) != 0) {
dmnsn_delete_display(display);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Drawing to openGL failed! ---\n");
return EXIT_FAILURE;
}
@@ -77,7 +77,7 @@ main() {
if (dmnsn_finish_progress(progress) != 0) {
dmnsn_delete_display(display);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Raytracing failed! ---\n");
return EXIT_FAILURE;
}
@@ -86,7 +86,7 @@ main() {
printf("Drawing to OpenGL\n");
if (dmnsn_gl_write_canvas(scene->canvas) != 0) {
dmnsn_delete_display(display);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Drawing to openGL failed! ---\n");
return EXIT_FAILURE;
}
@@ -100,7 +100,7 @@ main() {
canvas = dmnsn_gl_read_canvas(0, 0, scene->canvas->x, scene->canvas->y);
if (!canvas) {
dmnsn_delete_display(display);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Reading canvas from GL buffer failed! ---\n");
return EXIT_FAILURE;
}
@@ -110,7 +110,7 @@ main() {
if (dmnsn_gl_write_canvas(canvas) != 0) {
dmnsn_delete_canvas(canvas);
dmnsn_delete_display(display);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Drawing to openGL failed! ---\n");
return EXIT_FAILURE;
}
@@ -121,6 +121,6 @@ main() {
dmnsn_delete_canvas(canvas);
dmnsn_delete_display(display);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return EXIT_SUCCESS;
}
diff --git a/tests/libdimension/png.c b/tests/libdimension/png.c
index 0937a87..611ab11 100644
--- a/tests/libdimension/png.c
+++ b/tests/libdimension/png.c
@@ -43,7 +43,7 @@ main() {
/* Optimize the canvas for PNG export */
if (dmnsn_png_optimize_canvas(scene->canvas) != 0) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Couldn't optimize canvas for PNG! ---\n");
return EXIT_FAILURE;
}
@@ -52,7 +52,7 @@ main() {
printf("Rendering scene\n");
if (dmnsn_raytrace_scene(scene) != 0) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Raytracing failed! ---\n");
return EXIT_FAILURE;
}
@@ -62,20 +62,20 @@ main() {
printf("Writing scene to PNG\n");
ofile = fopen("png1.png", "wb");
if (!ofile) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Couldn't open 'png1.png' for writing! ---\n");
return EXIT_FAILURE;
}
if (dmnsn_png_write_canvas(scene->canvas, ofile) != 0) {
fclose(ofile);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
fprintf(stderr, "--- Writing canvas to PNG failed! ---\n");
return EXIT_FAILURE;
}
fclose(ofile);
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
/*
* Now test PNG import/export
diff --git a/tests/libdimension/tests.c b/tests/libdimension/tests.c
index 783c0f9..41c7d78 100644
--- a/tests/libdimension/tests.c
+++ b/tests/libdimension/tests.c
@@ -45,7 +45,7 @@ dmnsn_new_default_scene()
/* Allocate a canvas */
scene->canvas = dmnsn_new_canvas(768, 480);
if (!scene->canvas) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return NULL;
}
@@ -67,7 +67,7 @@ dmnsn_new_default_scene()
/* Create a perspective camera */
scene->camera = dmnsn_new_perspective_camera();
if (!scene->camera) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return NULL;
}
dmnsn_set_perspective_camera_trans(scene->camera, trans);
@@ -76,20 +76,20 @@ dmnsn_new_default_scene()
sphere = dmnsn_new_sphere();
if (!sphere) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return NULL;
}
dmnsn_array_push(scene->objects, &sphere);
sphere->texture = dmnsn_new_texture();
if (!sphere->texture) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return NULL;
}
sphere->texture->pigment = dmnsn_new_solid_pigment(dmnsn_white);
if (!sphere->texture->pigment) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return NULL;
}
@@ -99,20 +99,20 @@ dmnsn_new_default_scene()
cube = dmnsn_new_cube();
if (!cube) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return NULL;
}
dmnsn_array_push(scene->objects, &cube);
cube->texture = dmnsn_new_texture();
if (!cube->texture) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return NULL;
}
cube->texture->pigment = dmnsn_new_solid_pigment(dmnsn_black);
if (!cube->texture->pigment) {
- dmnsn_delete_default_scene(scene);
+ dmnsn_delete_scene(scene);
return NULL;
}
@@ -123,24 +123,6 @@ dmnsn_new_default_scene()
return scene;
}
-void
-dmnsn_delete_default_scene(dmnsn_scene *scene)
-{
- dmnsn_object *sphere = NULL, *cube = NULL;
-
- if (dmnsn_array_size(scene->objects) >= 1)
- dmnsn_array_get(scene->objects, 0, &sphere);
-
- if (dmnsn_array_size(scene->objects) >= 2)
- dmnsn_array_get(scene->objects, 1, &cube);
-
- dmnsn_delete_object(cube);
- dmnsn_delete_object(sphere);
- dmnsn_delete_camera(scene->camera);
- dmnsn_delete_canvas(scene->canvas);
- dmnsn_delete_scene(scene);
-}
-
/* XIfEvent callback */
static Bool
WaitForNotify(Display *d, XEvent *e, char *arg)
diff --git a/tests/libdimension/tests.h b/tests/libdimension/tests.h
index 68cb726..45b316a 100644
--- a/tests/libdimension/tests.h
+++ b/tests/libdimension/tests.h
@@ -36,7 +36,6 @@ extern "C" {
*/
dmnsn_scene *dmnsn_new_default_scene();
-void dmnsn_delete_default_scene(dmnsn_scene *scene);
/*
* Windowing