From fdd96dbc274aa695fa334cba3d066ce9a5118169 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Sat, 2 Aug 2014 00:51:55 -0700 Subject: [PATCH] Print pixel progress Not entirely convinced this is a good idea yet. It slows down rendering by almost 2x. --- src/scene.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/scene.cc b/src/scene.cc index 6587412..e8ce71d 100644 --- a/src/scene.cc +++ b/src/scene.cc @@ -155,17 +155,26 @@ Scene::render() pixels = new Color[width * height]; + unsigned long numPrimaryRays = width * height; + Ray primary_ray; Vector3 o, d; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { - primary_ray = mCamera->compute_primary_ray(x, width, y, height); mStats.primaryRays++; + + printf("\rRendering pixels... (%ld/%ld) %3.0f%%", + mStats.primaryRays, numPrimaryRays, + ((float)mStats.primaryRays / (float)numPrimaryRays) * 100); + + primary_ray = mCamera->compute_primary_ray(x, width, y, height); Color c = trace_ray(primary_ray); pixels[y * width + x] = c; } } + printf("\n"); + end = std::chrono::system_clock::now(); std::chrono::duration seconds = end - start;