diff --git a/apps/raydiance.cpp b/apps/raydiance.cpp index dee1d7f..f996718 100644 --- a/apps/raydiance.cpp +++ b/apps/raydiance.cpp @@ -4,17 +4,49 @@ #include #include #include +#include -int main() { - std::ofstream imgOut{file::openOutStream("img")}; +int main(int argc, char *argv[]) { + std::string sceneConfigPath; + std::string imgOutName; + + // Get file paths from command line arguments + int opt; + while ((opt = getopt(argc, argv, "s:o:")) != -1) { + switch (opt) { + case 's': + sceneConfigPath = optarg; + break; + case 'o': + imgOutName = optarg; + break; + default: + std::cerr << "Invalid option.\n\n" + << "Usage: raydiance -s [-o ]\n"; + return 1; + } + } + + if (sceneConfigPath.empty()) { + std::cerr << "Scene config file is required.\n\n" + << "Usage: vb2c -s [-o ]\n"; + return 1; + } + + // The default output image name is "img" + if (imgOutName.empty()) { + imgOutName = "img"; + } + + std::ofstream imgOut{file::openOutStream(imgOutName)}; + + std::ifstream sceneConfigFile{sceneConfigPath}; if (!imgOut.is_open()) { std::cerr << "Failed to open file for writing.\n"; return 1; } - std::ifstream sceneConfigFile{"scene.json"}; - if (!sceneConfigFile.is_open()) { std::cerr << "Failed to open scene config file.\n"; return 1;