00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "stdafx.h"
00027 #include "api.h"
00028 #include "probes.h"
00029 #include "parser.h"
00030 #include "parallel.h"
00031 #ifdef PBRT_HAS_LIBSDL
00032 #include "SDL_main.h"
00033 #endif // PBRT_HAS_LIBSDL
00034
00035
00036 int main(int argc, char *argv[]) {
00037 Options options;
00038 vector<string> filenames;
00039
00040 for (int i = 1; i < argc; ++i) {
00041 if (!strcmp(argv[i], "--ncores")) options.nCores = atoi(argv[++i]);
00042 else if (!strcmp(argv[i], "--outfile")) options.imageFile = argv[++i];
00043 else if (!strcmp(argv[i], "--quick")) options.quickRender = true;
00044 else if (!strcmp(argv[i], "--quiet")) options.quiet = true;
00045 else if (!strcmp(argv[i], "--verbose")) options.verbose = true;
00046 #ifdef PBRT_HAS_LIBSDL
00047 else if (!strcmp(argv[i], "--window")) options.openWindow = true;
00048 #endif
00049 else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
00050 printf("usage: pbrt [--ncores n] [--outfile filename] [--quick] [--quiet] "
00051 #ifdef PBRT_HAS_LIBSDL
00052 "[--window] "
00053 #endif
00054 "[--verbose] [--help] <filename.pbrt> ...\n");
00055 return 0;
00056 }
00057 else filenames.push_back(argv[i]);
00058 }
00059
00060
00061 if (!options.quiet) {
00062 printf("pbrt version %s of %s at %s [Detected %d core(s)]\n",
00063 PBRT_VERSION, __DATE__, __TIME__, NumSystemCores());
00064 printf("Copyright (c)1998-2010 Matt Pharr and Greg Humphreys.\n");
00065 printf("The source code to pbrt (but *not* the book contents) is covered by the GNU GPL.\n");
00066 printf("See the file COPYING.txt for the conditions of the license.\n");
00067 fflush(stdout);
00068 }
00069 pbrtInit(options);
00070
00071 PBRT_STARTED_PARSING();
00072 if (filenames.size() == 0) {
00073
00074 ParseFile("-");
00075 } else {
00076
00077 for (u_int i = 0; i < filenames.size(); i++)
00078 if (!ParseFile(filenames[i]))
00079 Error("Couldn't open scene file \"%s\"", filenames[i].c_str());
00080 }
00081 pbrtCleanup();
00082 return 0;
00083 }
00084
00085