summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-11-09 11:40:38 -0500
committerTavian Barnes <tavianator@gmail.com>2009-11-09 11:40:38 -0500
commita26ca6375382107037807abcd7ad4cdfd8cde2d6 (patch)
treee3c3d17993d7705bf892cf88ffa20443c1ed4f8d
parent354f43020d956e7f02dcc81feab13e6fa0e98e10 (diff)
downloaddimension-a26ca6375382107037807abcd7ad4cdfd8cde2d6.tar.xz
Add a light to the default test scene.
-rw-r--r--tests/libdimension/tests.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/tests/libdimension/tests.c b/tests/libdimension/tests.c
index 41c7d78..5a0b4cf 100644
--- a/tests/libdimension/tests.c
+++ b/tests/libdimension/tests.c
@@ -23,10 +23,6 @@ dmnsn_scene *
dmnsn_new_default_scene()
{
dmnsn_scene *scene;
- dmnsn_object *sphere, *cube;
- dmnsn_matrix trans;
- dmnsn_sRGB sRGB;
- dmnsn_color color;
/* Allocate a new scene */
scene = dmnsn_new_scene();
@@ -35,12 +31,9 @@ dmnsn_new_default_scene()
}
/* Background color */
- sRGB.R = 0.0;
- sRGB.G = 0.0;
- sRGB.B = 0.1;
- color = dmnsn_color_from_sRGB(sRGB);
- color.filter = 0.1;
- scene->background = color;
+ dmnsn_sRGB sRGB = { .R = 0.0, .G = 0.0, .B = 0.1 };
+ scene->background = dmnsn_color_from_sRGB(sRGB);
+ scene->background.filter = 0.1;
/* Allocate a canvas */
scene->canvas = dmnsn_new_canvas(768, 480);
@@ -50,7 +43,7 @@ dmnsn_new_default_scene()
}
/* Set up the transformation matrix for the perspective camera */
- trans = dmnsn_scale_matrix(
+ dmnsn_matrix trans = dmnsn_scale_matrix(
dmnsn_vector_construct(
((double)scene->canvas->x)/scene->canvas->y, 1.0, 1.0
)
@@ -74,7 +67,7 @@ dmnsn_new_default_scene()
/* Now make our objects */
- sphere = dmnsn_new_sphere();
+ dmnsn_object *sphere = dmnsn_new_sphere();
if (!sphere) {
dmnsn_delete_scene(scene);
return NULL;
@@ -97,7 +90,7 @@ dmnsn_new_default_scene()
dmnsn_scale_matrix(dmnsn_vector_construct(1.25, 1.25, 1.25))
);
- cube = dmnsn_new_cube();
+ dmnsn_object *cube = dmnsn_new_cube();
if (!cube) {
dmnsn_delete_scene(scene);
return NULL;
@@ -120,6 +113,18 @@ dmnsn_new_default_scene()
dmnsn_rotation_matrix(dmnsn_vector_construct(0.75, 0.0, 0.0))
);
+ /* Now make a light */
+
+ dmnsn_light *light = dmnsn_new_point_light(
+ dmnsn_vector_construct(0.0, 3.0, 0.0),
+ dmnsn_white
+ );
+ if (!light) {
+ dmnsn_delete_scene(scene);
+ return NULL;
+ }
+ dmnsn_array_push(scene->lights, &light);
+
return scene;
}