|
186 | 186 |
|
187 | 187 | <div class='together'>
|
188 | 188 | Our program outputs the image to the standard output stream (`std::cout`), so leave that alone and
|
189 |
| -instead write to the error output stream (`std::cerr`): |
| 189 | +instead write to the logging output stream (`std::clog`): |
190 | 190 |
|
191 | 191 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
192 | 192 | for (int j = image_height-1; j >= 0; --j) {
|
193 | 193 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
|
194 |
| - std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush; |
| 194 | + std::clog << "\rScanlines remaining: " << j << ' ' << std::flush; |
195 | 195 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
196 | 196 | for (int i = 0; i < image_width; ++i) {
|
197 | 197 | auto r = double(i) / (image_width-1);
|
|
208 | 208 |
|
209 | 209 |
|
210 | 210 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
|
211 |
| - std::cerr << "\nDone.\n"; |
| 211 | + std::clog << "\nDone.\n"; |
212 | 212 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
213 | 213 | [Listing [main-progress]: <kbd>[main.cc]</kbd> Main render loop with progress reporting]
|
214 | 214 | </div>
|
|
402 | 402 | std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
|
403 | 403 |
|
404 | 404 | for (int j = image_height-1; j >= 0; --j) {
|
405 |
| - std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush; |
| 405 | + std::clog << "\rScanlines remaining: " << j << ' ' << std::flush; |
406 | 406 | for (int i = 0; i < image_width; ++i) {
|
407 | 407 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
|
408 | 408 | color pixel_color(double(i)/(image_width-1), double(j)/(image_height-1), 0.25);
|
|
411 | 411 | }
|
412 | 412 | }
|
413 | 413 |
|
414 |
| - std::cerr << "\nDone.\n"; |
| 414 | + std::clog << "\nDone.\n"; |
415 | 415 | }
|
416 | 416 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
417 | 417 | [Listing [ppm-2]: <kbd>[main.cc]</kbd> Final code for the first PPM image]
|
|
548 | 548 | std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";
|
549 | 549 |
|
550 | 550 | for (int j = image_height-1; j >= 0; --j) {
|
551 |
| - std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush; |
| 551 | + std::clog << "\rScanlines remaining: " << j << ' ' << std::flush; |
552 | 552 | for (int i = 0; i < image_width; ++i) {
|
553 | 553 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
|
554 | 554 | auto u = double(i) / (image_width-1);
|
|
560 | 560 | }
|
561 | 561 | }
|
562 | 562 |
|
563 |
| - std::cerr << "\nDone.\n"; |
| 563 | + std::clog << "\nDone.\n"; |
564 | 564 | }
|
565 | 565 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
566 | 566 | [Listing [main-blue-white-blend]: <kbd>[main.cc]</kbd> Rendering a blue-to-white gradient]
|
|
1254 | 1254 | std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n";
|
1255 | 1255 |
|
1256 | 1256 | for (int j = image_height-1; j >= 0; --j) {
|
1257 |
| - std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush; |
| 1257 | + std::clog << "\rScanlines remaining: " << j << ' ' << std::flush; |
1258 | 1258 | for (int i = 0; i < image_width; ++i) {
|
1259 | 1259 | auto u = double(i) / (image_width-1);
|
1260 | 1260 | auto v = double(j) / (image_height-1);
|
|
1266 | 1266 | }
|
1267 | 1267 | }
|
1268 | 1268 |
|
1269 |
| - std::cerr << "\nDone.\n"; |
| 1269 | + std::clog << "\nDone.\n"; |
1270 | 1270 | }
|
1271 | 1271 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
1272 | 1272 | [Listing [main-with-rtweekend-h]: <kbd>[main.cc]</kbd> The new main with hittables]
|
|
1591 | 1591 | std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";
|
1592 | 1592 |
|
1593 | 1593 | for (int j = image_height-1; j >= 0; --j) {
|
1594 |
| - std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush; |
| 1594 | + std::clog << "\rScanlines remaining: " << j << ' ' << std::flush; |
1595 | 1595 | for (int i = 0; i < image_width; ++i) {
|
1596 | 1596 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
|
1597 | 1597 | color pixel_color(0, 0, 0);
|
|
1606 | 1606 | }
|
1607 | 1607 | }
|
1608 | 1608 |
|
1609 |
| - std::cerr << "\nDone.\n"; |
| 1609 | + std::clog << "\nDone.\n"; |
1610 | 1610 | }
|
1611 | 1611 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
1612 | 1612 | [Listing [main-multi-sample]: <kbd>[main.cc]</kbd> Rendering with multi-sampled pixels]
|
|
1770 | 1770 | std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";
|
1771 | 1771 |
|
1772 | 1772 | for (int j = image_height-1; j >= 0; --j) {
|
1773 |
| - std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush; |
| 1773 | + std::clog << "\rScanlines remaining: " << j << ' ' << std::flush; |
1774 | 1774 | for (int i = 0; i < image_width; ++i) {
|
1775 | 1775 | color pixel_color(0, 0, 0);
|
1776 | 1776 | for (int s = 0; s < samples_per_pixel; ++s) {
|
|
1785 | 1785 | }
|
1786 | 1786 | }
|
1787 | 1787 |
|
1788 |
| - std::cerr << "\nDone.\n"; |
| 1788 | + std::clog << "\nDone.\n"; |
1789 | 1789 | }
|
1790 | 1790 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
1791 | 1791 | [Listing [ray-color-depth]: <kbd>[main.cc]</kbd> ray_color() with depth limiting]
|
|
2370 | 2370 | std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";
|
2371 | 2371 |
|
2372 | 2372 | for (int j = image_height-1; j >= 0; --j) {
|
2373 |
| - std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush; |
| 2373 | + std::clog << "\rScanlines remaining: " << j << ' ' << std::flush; |
2374 | 2374 | for (int i = 0; i < image_width; ++i) {
|
2375 | 2375 | color pixel_color(0, 0, 0);
|
2376 | 2376 | for (int s = 0; s < samples_per_pixel; ++s) {
|
|
2383 | 2383 | }
|
2384 | 2384 | }
|
2385 | 2385 |
|
2386 |
| - std::cerr << "\nDone.\n"; |
| 2386 | + std::clog << "\nDone.\n"; |
2387 | 2387 | }
|
2388 | 2388 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2389 | 2389 | [Listing [scene-with-metal]: <kbd>[main.cc]</kbd> Scene with metal spheres]
|
|
2829 | 2829 | std::cout << "P3\n" << image_width << " " << image_height << "\n255\n";
|
2830 | 2830 |
|
2831 | 2831 | for (int j = image_height-1; j >= 0; --j) {
|
2832 |
| - std::cerr << "\rScanlines remaining: " << j << ' ' << std::flush; |
| 2832 | + std::clog << "\rScanlines remaining: " << j << ' ' << std::flush; |
2833 | 2833 | for (int i = 0; i < image_width; ++i) {
|
2834 | 2834 | color pixel_color(0,0,0);
|
2835 | 2835 | for (int s = 0; s < samples_per_pixel; ++s) {
|
|
2842 | 2842 | }
|
2843 | 2843 | }
|
2844 | 2844 |
|
2845 |
| - std::cerr << "\nDone.\n"; |
| 2845 | + std::clog << "\nDone.\n"; |
2846 | 2846 | }
|
2847 | 2847 |
|
2848 | 2848 | public:
|
|
0 commit comments