diff --git a/example02_threaded_raytracing/src/main.cpp b/example02_threaded_raytracing/src/main.cpp index 9e4c2cb..acc7aa1 100644 --- a/example02_threaded_raytracing/src/main.cpp +++ b/example02_threaded_raytracing/src/main.cpp @@ -127,10 +127,14 @@ int main(int argc, char **argv) { // auto pixels = Ex02::RT::renderGraySphere( // outputWidth, outputHeight, threadCount); + std::cout << "Rendering image of width " << outputWidth << " and height " + << outputHeight << " with " << threadCount << " thread(s)..." + << std::endl; auto pixels = Ex02::RT::renderColorsWithSpheres(outputWidth, outputHeight, threadCount); - pixels.writeToFile(outputFile); + auto outFilename = pixels.writeToFile(outputFile); + std::cout << "Rendered image saved to " << outFilename << std::endl; return 0; } diff --git a/example02_threaded_raytracing/src/rayTracer.cpp b/example02_threaded_raytracing/src/rayTracer.cpp index 5208c3c..50036d0 100644 --- a/example02_threaded_raytracing/src/rayTracer.cpp +++ b/example02_threaded_raytracing/src/rayTracer.cpp @@ -26,8 +26,9 @@ const Ex02::RT::Pixel &Ex02::RT::Image::getPixel(unsigned int x, return data.at(x + y * width); } -void Ex02::RT::Image::writeToFile(const std::string &filename) const { - std::ofstream out(filename + ".ppm"); +std::string Ex02::RT::Image::writeToFile(const std::string &filename) const { + std::string outfilename = filename + ".ppm"; + std::ofstream out(outfilename); out << "P3\n" << width << ' ' << data.size() / width << " 255" << '\n'; for (unsigned int j = 0; j < data.size() / width; ++j) { @@ -38,6 +39,8 @@ void Ex02::RT::Image::writeToFile(const std::string &filename) const { } out << '\n'; } + + return outfilename; } /* diff --git a/example02_threaded_raytracing/src/rayTracer.hpp b/example02_threaded_raytracing/src/rayTracer.hpp index aa425b0..2f5307d 100644 --- a/example02_threaded_raytracing/src/rayTracer.hpp +++ b/example02_threaded_raytracing/src/rayTracer.hpp @@ -31,7 +31,8 @@ public: Pixel &getPixel(unsigned int x, unsigned int y); const Pixel &getPixel(unsigned int x, unsigned int y) const; - void writeToFile(const std::string &filename) const; + // returns actual output filename + std::string writeToFile(const std::string &filename) const; private: unsigned int width;