| 18 |
|
#include "random.h" |
| 19 |
|
#include "paths.h" |
| 20 |
|
#include "view.h" |
| 21 |
+ |
#include "pmapray.h" |
| 22 |
|
|
| 23 |
|
extern char *progname; /* global argv[0] */ |
| 24 |
|
|
| 55 |
|
static void sigdie(int signo, char *msg); |
| 56 |
|
static void printdefaults(void); |
| 57 |
|
|
| 57 |
– |
|
| 58 |
|
int |
| 59 |
|
main(int argc, char *argv[]) |
| 60 |
|
{ |
| 61 |
|
#define check(ol,al) if (argv[i][ol] || \ |
| 62 |
|
badarg(argc-i-1,argv+i+1,al)) \ |
| 63 |
|
goto badopt |
| 64 |
< |
#define bool(olen,var) switch (argv[i][olen]) { \ |
| 64 |
> |
#define check_bool(olen,var) switch (argv[i][olen]) { \ |
| 65 |
|
case '\0': var = !var; break; \ |
| 66 |
|
case 'y': case 'Y': case 't': case 'T': \ |
| 67 |
|
case '+': case '1': var = 1; break; \ |
| 83 |
|
specthresh = .3; |
| 84 |
|
specjitter = 1.; |
| 85 |
|
maxdepth = 6; |
| 86 |
< |
minweight = 1e-2; |
| 86 |
> |
minweight = 1e-3; |
| 87 |
|
ambacc = 0.3; |
| 88 |
|
ambres = 32; |
| 89 |
|
ambdiv = 256; |
| 147 |
|
} |
| 148 |
|
break; |
| 149 |
|
case 'b': /* grayscale */ |
| 150 |
< |
bool(2,greyscale); |
| 150 |
> |
check_bool(2,greyscale); |
| 151 |
|
break; |
| 152 |
|
case 'p': /* pixel */ |
| 153 |
|
switch (argv[i][2]) { |
| 171 |
|
break; |
| 172 |
|
case 'w': /* warnings */ |
| 173 |
|
rval = erract[WARNING].pf != NULL; |
| 174 |
< |
bool(2,rval); |
| 174 |
> |
check_bool(2,rval); |
| 175 |
|
if (rval) erract[WARNING].pf = wputs; |
| 176 |
|
else erract[WARNING].pf = NULL; |
| 177 |
|
break; |
| 197 |
|
/* set up signal handling */ |
| 198 |
|
sigdie(SIGINT, "Interrupt"); |
| 199 |
|
sigdie(SIGTERM, "Terminate"); |
| 200 |
< |
#ifndef _WIN32 |
| 200 |
> |
#if !defined(_WIN32) && !defined(_WIN64) |
| 201 |
|
sigdie(SIGHUP, "Hangup"); |
| 202 |
|
sigdie(SIGPIPE, "Broken pipe"); |
| 203 |
|
sigdie(SIGALRM, "Alarm clock"); |
| 227 |
|
/* set up output & start process(es) */ |
| 228 |
|
SET_FILE_BINARY(stdout); |
| 229 |
|
|
| 230 |
< |
ray_init(octnm); |
| 231 |
< |
|
| 230 |
> |
ray_init(octnm); /* also calls ray_init_pmap() */ |
| 231 |
> |
|
| 232 |
> |
/* temporary shortcut, until winrview is refactored into a "device" */ |
| 233 |
> |
#ifndef WIN_RVIEW |
| 234 |
|
rview(); /* run interactive viewer */ |
| 235 |
|
|
| 236 |
+ |
|
| 237 |
|
devclose(); /* close output device */ |
| 238 |
+ |
#endif |
| 239 |
|
|
| 240 |
+ |
/* PMAP: free photon maps */ |
| 241 |
+ |
ray_done_pmap(); |
| 242 |
+ |
|
| 243 |
+ |
#ifdef WIN_RVIEW |
| 244 |
+ |
return 1; |
| 245 |
+ |
#endif |
| 246 |
|
quit(0); |
| 247 |
|
|
| 248 |
|
badopt: |
| 251 |
|
return 1; /* pro forma return */ |
| 252 |
|
|
| 253 |
|
#undef check |
| 254 |
< |
#undef bool |
| 254 |
> |
#undef check_bool |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
|
| 258 |
|
void |
| 259 |
|
wputs( /* warning output function */ |
| 260 |
< |
char *s |
| 260 |
> |
const char *s |
| 261 |
|
) |
| 262 |
|
{ |
| 263 |
|
int lasterrno = errno; |
| 268 |
|
|
| 269 |
|
void |
| 270 |
|
eputs( /* put string to stderr */ |
| 271 |
< |
char *s |
| 271 |
> |
const char *s |
| 272 |
|
) |
| 273 |
|
{ |
| 274 |
|
static int midline = 0; |
| 297 |
|
if (gotsig++) /* two signals and we're gone! */ |
| 298 |
|
_exit(signo); |
| 299 |
|
|
| 300 |
< |
#ifndef _WIN32 |
| 300 |
> |
#if !defined(_WIN32) && !defined(_WIN64) |
| 301 |
|
alarm(15); /* allow 15 seconds to clean up */ |
| 302 |
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
| 303 |
|
#endif |