summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-05-03 16:01:38 +0800
committerKeuin <[email protected]>2022-05-03 16:01:38 +0800
commit3f0f7f72f0870ebbff13faa1b2c911de80fb7865 (patch)
tree17d63948555970862d9e068492a4d2d1a930e240
parent51fba0b6e75071e7ee63f9b53b6e972ccdb3bfce (diff)
Make program final_render supports NOPRINT environment variable.
-rw-r--r--main_final_render.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/main_final_render.cpp b/main_final_render.cpp
index 3c789af..277ffd9 100644
--- a/main_final_render.cpp
+++ b/main_final_render.cpp
@@ -134,6 +134,10 @@ int main(int argc, char *argv[]) {
printf("%s <image_width> <image_height> <sample_per_pixel>\n", argv[0]);
return 0;
}
+ const bool no_print = std::getenv("NOPRINT") != nullptr;
+ if (no_print) {
+ std::cerr << "NOPRINT is set. Result image won't be printed to STDOUT." << std::endl;
+ }
std::string s_image_width{argv[1]}, s_image_height{argv[2]}, s_spp{argv[3]};
uint32_t image_width = std::stoul(s_image_width);
uint32_t image_height = std::stoul(s_image_height);
@@ -151,5 +155,5 @@ int main(int argc, char *argv[]) {
tm.start_measure();
const auto image2 = image.gamma2();
tm.stop_measure();
- image2.write_plain_ppm(std::cout);
+ if (!no_print) image2.write_plain_ppm(std::cout);
} \ No newline at end of file