display percent of image complete on command line

git-svn-id: svn://anubis/fart/trunk@265 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2010-06-30 16:05:42 +00:00
parent 5b4a0692e3
commit 781b46dcd4

View File

@ -256,6 +256,11 @@ int main(int argc, char * argv[])
}
else
{
int total_pixels = height * width;
int total_pixels_1000 = total_pixels / 1000;
if (total_pixels_1000 < 1)
total_pixels_1000 = 1;
int pixel_num = 0;
/* "sequential" version */
for (int i = 0; i < height; i++)
{
@ -263,9 +268,16 @@ int main(int argc, char * argv[])
{
int pixel = i * width + j;
scene.renderPixel(j, i, &data[3 * pixel]);
pixel_num++;
if (pixel_num % total_pixels_1000 == 0)
{
double pct = 100.0 * pixel_num / (double) total_pixels;
printf("\e[8D%2.1f%%", pct);
}
}
}
printf("\e[8D");
}
gettimeofday(&after, NULL); /* stop timing */