From b749d0c61b0d33324b4f2f0a127f7a2571d9082f Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 8 Jul 2009 17:51:10 +0000 Subject: Don't animate in GL tests - turns out it's hellishly slow on slower computers. --- tests/glxx.cpp | 61 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'tests/glxx.cpp') diff --git a/tests/glxx.cpp b/tests/glxx.cpp index 419e43d..2515156 100644 --- a/tests/glxx.cpp +++ b/tests/glxx.cpp @@ -32,44 +32,43 @@ main() { // Create the default test scene Scene scene = Tests::default_scene(); - // Get the camera - Perspective_Camera& camera - = dynamic_cast(scene.camera()); - - // Find the cube - Cube* cube = 0; - for (Scene::Iterator i = scene.begin(); i != scene.end(); ++i) { - cube = dynamic_cast(&*i); - if (cube) { - break; - } - } - if (!cube) { - throw Dimension_Error("Couldn't find a cube in the default scene."); - } - - Raytracer raytracer(scene); - GL_Drawer drawer(scene.canvas()); + // Create a glX window Tests::Display display(scene.canvas()); - // Render the animation - const unsigned int frames = 10; - for (unsigned int i = 0; i < frames; ++i) { + { + Raytracer raytracer(scene); + GL_Drawer drawer(scene.canvas()); + // Render the scene - Progress rprogress = raytracer.render_async(); - std::cout << "Raytracing scene: " << rprogress << std::endl; - rprogress.finish(); + Progress progress = raytracer.render_async(); - // Display the frame + // Display the scene as it's rendered + while (progress.progress() < 1.0) { + drawer.draw(); + display.flush(); + } + + // Make sure we show the completed rendering + progress.finish(); drawer.draw(); display.flush(); - - // Rotate the cube and camera for the next frame - cube->trans( - inverse(Matrix::rotation(Vector(0.025, 0.0, 0.0)))*cube->trans() - ); - camera.trans(Matrix::rotation(Vector(0.0, -0.05, 0.0))*camera.trans()); } + // Pause for a second + sleep(1); + + // Read the canvas back from the GL buffer + GL_Reader reader; + Canvas canvas + = reader.read(0, 0, scene.canvas().width(), scene.canvas().height()); + + // And write it again + GL_Drawer drawer(canvas); + drawer.draw(); + display.flush(); + + // Pause for a second + sleep(1); + return EXIT_SUCCESS; } -- cgit v1.2.3