diff -r f22952603f29 -r 79b516a3803d ccdemos/realtime.cc --- a/ccdemos/realtime.cc Thu Nov 29 18:30:16 2007 +0100 +++ b/ccdemos/realtime.cc Fri Nov 30 00:44:51 2007 +0100 @@ -2,8 +2,8 @@ #include "raytracer.h" -int w = 512; -int h = 200; +int w = 480; +int h = 288; float *render_buffer; Raytracer rt; @@ -13,11 +13,9 @@ { rt.render(w, h, render_buffer); - if ( SDL_MUSTLOCK(screen) ) { - if ( SDL_LockSurface(screen) < 0 ) { + if (SDL_MUSTLOCK(screen)) + if (SDL_LockSurface(screen) < 0) return; - } - } Uint32 *bufp = (Uint32 *)screen->pixels; unsigned char c[3]; @@ -34,12 +32,13 @@ bufp++; } - if ( SDL_MUSTLOCK(screen) ) { + if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); - } - SDL_UpdateRect(screen, 0, 0, w, h); - SDL_Flip(screen); + if (screen->flags & SDL_DOUBLEBUF) + SDL_Flip(screen); + else + SDL_UpdateRect(screen, 0, 0, w, h); } int main() @@ -64,25 +63,29 @@ render_buffer = (float *) malloc(w*h*3*sizeof(float)); rt.setThreads(2); + rt.setMaxDepth(1); KdTree top; rt.setTop(&top); Light light1(Vector3(2.0, -5.0, -5.0), Colour(0.7, 0.3, 0.6)); + light1.castShadows(false); rt.addlight(&light1); Light light2(Vector3(-2.0, 10.0, 2.0), Colour(0.4, 0.6, 0.3)); + light2.castShadows(false); rt.addlight(&light2); Material mat_sph(Colour(1.0, 1.0, 1.0)); - for (int y=0; y<20; y++) - for (int x=0; x<20; x++) - rt.addshape(new Sphere(Vector3(x-10, (float)random()/RAND_MAX*5.0, y-10), 0.45, &mat_sph)); + for (int y=0; y<10; y++) + for (int x=0; x<10; x++) + rt.addshape(new Sphere(Vector3(x*2-10, (float)random()/RAND_MAX*5.0, y*2-10), 0.45, &mat_sph)); rt.setCamera(&cam); cam.setEye(Vector3(0,0,10)); /* build kd-tree */ + top.setMaxDepth(100); top.optimize(); /* loop... */