From 3f0f7f72f0870ebbff13faa1b2c911de80fb7865 Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 3 May 2022 16:01:38 +0800 Subject: Make program final_render supports NOPRINT environment variable. --- main_final_render.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 \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 -- cgit v1.2.3