| 104 | } |
| 105 | |
| 106 | void getargs(int argc, const char *argv[]) |
| 107 | { |
| 108 | bool help = false; |
| 109 | OIIO::ArgParse ap; |
| 110 | ap.options ("Usage: testrender [options] scene.xml output.exr", |
| 111 | "%*", get_filenames, "", |
| 112 | "--help", &help, "Print help message", |
| 113 | "-v", &verbose, "Verbose messages", |
| 114 | "--debug", &debug1, "Lots of debugging info", |
| 115 | "--debug2", &debug2, "Even more debugging info", |
| 116 | "--runstats", &runstats, "Print run statistics", |
| 117 | "--stats", &runstats, "", // DEPRECATED 1.7 |
| 118 | "--profile %@", &set_profile, NULL, "Print profile information", |
| 119 | "-r %d %d", &xres, &yres, "Render a WxH image", |
| 120 | "-aa %d", &aa, "Trace NxN rays per pixel", |
| 121 | "-t %d", &num_threads, "Render using N threads (default: auto-detect)", |
| 122 | "-O0", &O0, "Do no runtime shader optimization", |
| 123 | "-O1", &O1, "Do a little runtime shader optimization", |
| 124 | "-O2", &O2, "Do lots of runtime shader optimization", |
| 125 | "--debugnan", &debugnan, "Turn on 'debugnan' mode", |
| 126 | "--path %s", &shaderpath, "Specify oso search path", |
| 127 | "--options %s", &extraoptions, "Set extra OSL options", |
| 128 | NULL); |
| 129 | if (ap.parse(argc, argv) < 0) { |
| 130 | std::cerr << ap.geterror() << std::endl; |
| 131 | ap.usage (); |
| 132 | exit (EXIT_FAILURE); |
| 133 | } |
| 134 | if (help) { |
| 135 | std::cout << |
| 136 | "testrender -- Test Renderer for Open Shading Language\n" |
| 137 | OSL_COPYRIGHT_STRING "\n"; |
| 138 | ap.usage (); |
| 139 | exit (EXIT_SUCCESS); |
| 140 | } |
| 141 | if (scenefile.empty()) { |
| 142 | std::cerr << "testrender: Must specify an xml scene file to open\n"; |
| 143 | ap.usage(); |
| 144 | exit (EXIT_FAILURE); |
| 145 | } |
| 146 | if (imagefile.empty()) { |
| 147 | std::cerr << "testrender: Must specify a filename for output render\n"; |
| 148 | ap.usage(); |
| 149 | exit (EXIT_FAILURE); |
| 150 | } |
| 151 | if (debug1 || verbose) |
| 152 | errhandler.verbosity (ErrorHandler::VERBOSE); |
| 153 | } |
| 154 | |
| 155 | Vec3 strtovec(string_view str) { |
| 156 | Vec3 v(0, 0, 0); |