diff -r 5d043eeb09d9 -r 7079dcc3bd74 ccdemos/spheres_shadow.cc --- a/ccdemos/spheres_shadow.cc Fri Dec 14 10:34:31 2007 +0100 +++ b/ccdemos/spheres_shadow.cc Fri Dec 14 16:51:22 2007 +0100 @@ -1,15 +1,16 @@ #include "raytracer.h" -#include "kdtree.h" +#include "octree.h" + #include "image.h" +#include "common_sdl.h" -int main() +int main(int argc, char **argv) { Raytracer rt; - rt.setThreads(2); rt.setOversample(0); rt.setSubsample(8); - KdTree top; + Octree top; rt.setTop(&top); Light light1(Vector3(0.0, 5.0, -5.0), Colour(0.7, 0.3, 0.6)); @@ -41,22 +42,28 @@ cam.setEye(Vector3(0,0,15)); rt.setCamera(&cam); - int w = 800; - int h = 600; - Float *fdata = (Float *) malloc(w*h*3*sizeof(Float)); - rt.render(w, h, fdata); - - struct image *img; - new_image(&img, w, h, 3); + w = 800; + h = 600; - Float *fd = fdata; - for (char *cd = img->data; cd != img->data + w*h*3; cd++, fd++) { - if (*fd > 1.0) - *cd = 255; - else - *cd = (unsigned char)(*fd * 255.0); + if (argc == 2 && !strcmp(argv[1], "-i")) + loop_sdl(rt, cam); + else + { + Float *fdata = (Float *) malloc(w*h*3*sizeof(Float)); + rt.render(w, h, fdata); + + struct image *img; + new_image(&img, w, h, 3); + + Float *fd = fdata; + for (char *cd = img->data; cd != img->data + w*h*3; cd++, fd++) { + if (*fd > 1.0) + *cd = 255; + else + *cd = (unsigned char)(*fd * 255.0); + } + free(fdata); + save_png("spheres_shadow.png", img); + destroy_image(&img); } - free(fdata); - save_png("spheres_shadow.png", img); - destroy_image(&img); }