1 |
greg |
2.1 |
#ifndef lint |
2 |
greg |
2.30 |
static const char RCSid[] = "$Id: rpmain.c,v 2.29 2023/11/17 20:02:07 greg Exp $"; |
3 |
greg |
2.1 |
#endif |
4 |
|
|
/* |
5 |
|
|
* rpmain.c - main for rpict batch rendering program |
6 |
|
|
*/ |
7 |
|
|
|
8 |
greg |
2.2 |
#include "copyright.h" |
9 |
greg |
2.1 |
|
10 |
greg |
2.10 |
#include <time.h> |
11 |
schorsch |
2.3 |
#include <signal.h> |
12 |
|
|
|
13 |
|
|
#include "platform.h" |
14 |
schorsch |
2.6 |
#include "rtprocess.h" /* getpid() */ |
15 |
greg |
2.1 |
#include "ray.h" |
16 |
|
|
#include "source.h" |
17 |
|
|
#include "ambient.h" |
18 |
|
|
#include "random.h" |
19 |
|
|
#include "paths.h" |
20 |
|
|
#include "view.h" |
21 |
greg |
2.16 |
#include "pmapray.h" |
22 |
greg |
2.1 |
|
23 |
|
|
/* persistent processes define */ |
24 |
|
|
#ifdef F_SETLKW |
25 |
|
|
#define PERSIST 1 /* normal persist */ |
26 |
|
|
#define PARALLEL 2 /* parallel persist */ |
27 |
|
|
#define PCHILD 3 /* child of normal persist */ |
28 |
|
|
#endif |
29 |
|
|
|
30 |
|
|
char *progname; /* argv[0] */ |
31 |
|
|
char *octname; /* octree name */ |
32 |
|
|
char *sigerr[NSIG]; /* signal error messages */ |
33 |
|
|
char *shm_boundary = NULL; /* boundary of shared memory */ |
34 |
|
|
char *errfile = NULL; /* error output file */ |
35 |
|
|
|
36 |
|
|
extern time_t time(); |
37 |
|
|
extern time_t tstart; /* start time */ |
38 |
|
|
|
39 |
|
|
extern int ralrm; /* seconds between reports */ |
40 |
|
|
|
41 |
|
|
extern VIEW ourview; /* viewing parameters */ |
42 |
|
|
|
43 |
|
|
extern int hresolu; /* horizontal resolution */ |
44 |
|
|
extern int vresolu; /* vertical resolution */ |
45 |
|
|
extern double pixaspect; /* pixel aspect ratio */ |
46 |
|
|
|
47 |
|
|
extern int psample; /* pixel sample size */ |
48 |
|
|
extern double maxdiff; /* max. sample difference */ |
49 |
|
|
extern double dstrpix; /* square pixel distribution */ |
50 |
|
|
|
51 |
|
|
extern double mblur; /* motion blur parameter */ |
52 |
|
|
|
53 |
greg |
2.9 |
extern double dblur; /* depth-of-field blur parameter */ |
54 |
|
|
|
55 |
greg |
2.28 |
RGBPRIMP out_prims = stdprims; /* output color primitives */ |
56 |
|
|
static RGBPRIMS our_prims; /* private output color primitives */ |
57 |
|
|
|
58 |
schorsch |
2.8 |
static void onsig(int signo); |
59 |
|
|
static void sigdie(int signo, char *msg); |
60 |
|
|
static void printdefaults(void); |
61 |
greg |
2.21 |
/* rpict additional features */ |
62 |
|
|
#ifdef PERSIST |
63 |
|
|
#define RPICT_FEATURES "Persist\nParallelPersist\n" \ |
64 |
greg |
2.29 |
"ParticipatingMedia=Mist\n" \ |
65 |
greg |
2.22 |
"Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
66 |
|
|
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
67 |
|
|
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
68 |
|
|
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
69 |
greg |
2.23 |
"AdaptiveShadowTesting\nOutputs=v,l\n" |
70 |
greg |
2.21 |
#else |
71 |
|
|
#define RPICT_FEATURES "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
72 |
greg |
2.29 |
"ParticipatingMedia=Mist\n" \ |
73 |
greg |
2.22 |
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
74 |
|
|
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
75 |
|
|
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
76 |
greg |
2.23 |
"AdaptiveShadowTesting\nOutputs=v,l\n" |
77 |
greg |
2.21 |
#endif |
78 |
greg |
2.1 |
|
79 |
|
|
|
80 |
|
|
int |
81 |
schorsch |
2.8 |
main(int argc, char *argv[]) |
82 |
greg |
2.1 |
{ |
83 |
|
|
#define check(ol,al) if (argv[i][ol] || \ |
84 |
|
|
badarg(argc-i-1,argv+i+1,al)) \ |
85 |
|
|
goto badopt |
86 |
schorsch |
2.18 |
#define check_bool(olen,var) switch (argv[i][olen]) { \ |
87 |
greg |
2.1 |
case '\0': var = !var; break; \ |
88 |
|
|
case 'y': case 'Y': case 't': case 'T': \ |
89 |
|
|
case '+': case '1': var = 1; break; \ |
90 |
|
|
case 'n': case 'N': case 'f': case 'F': \ |
91 |
|
|
case '-': case '0': var = 0; break; \ |
92 |
|
|
default: goto badopt; } |
93 |
|
|
char *err; |
94 |
|
|
char *recover = NULL; |
95 |
|
|
char *outfile = NULL; |
96 |
|
|
char *zfile = NULL; |
97 |
|
|
int loadflags = ~IO_FILES; |
98 |
|
|
int seqstart = 0; |
99 |
|
|
int persist = 0; |
100 |
greg |
2.15 |
int duped1 = -1; |
101 |
greg |
2.1 |
int rval; |
102 |
|
|
int i; |
103 |
|
|
/* record start time */ |
104 |
|
|
tstart = time((time_t *)NULL); |
105 |
|
|
/* global program name */ |
106 |
|
|
progname = argv[0] = fixargv0(argv[0]); |
107 |
greg |
2.21 |
/* feature check only? */ |
108 |
|
|
strcat(RFeatureList, RPICT_FEATURES); |
109 |
greg |
2.25 |
if (argc > 1 && !strcmp(argv[1], "-features")) |
110 |
greg |
2.21 |
return feature_status(argc-2, argv+2); |
111 |
greg |
2.1 |
/* option city */ |
112 |
|
|
for (i = 1; i < argc; i++) { |
113 |
|
|
/* expand arguments */ |
114 |
|
|
while ((rval = expandarg(&argc, &argv, i)) > 0) |
115 |
|
|
; |
116 |
|
|
if (rval < 0) { |
117 |
|
|
sprintf(errmsg, "cannot expand '%s'", argv[i]); |
118 |
|
|
error(SYSTEM, errmsg); |
119 |
|
|
} |
120 |
|
|
if (argv[i] == NULL || argv[i][0] != '-') |
121 |
|
|
break; /* break from options */ |
122 |
|
|
if (!strcmp(argv[i], "-version")) { |
123 |
|
|
puts(VersionID); |
124 |
|
|
quit(0); |
125 |
|
|
} |
126 |
|
|
if (!strcmp(argv[i], "-defaults") || |
127 |
|
|
!strcmp(argv[i], "-help")) { |
128 |
|
|
printdefaults(); |
129 |
|
|
quit(0); |
130 |
|
|
} |
131 |
|
|
rval = getrenderopt(argc-i, argv+i); |
132 |
|
|
if (rval >= 0) { |
133 |
|
|
i += rval; |
134 |
|
|
continue; |
135 |
|
|
} |
136 |
|
|
rval = getviewopt(&ourview, argc-i, argv+i); |
137 |
|
|
if (rval >= 0) { |
138 |
|
|
i += rval; |
139 |
|
|
continue; |
140 |
|
|
} |
141 |
|
|
/* rpict options */ |
142 |
|
|
switch (argv[i][1]) { |
143 |
|
|
case 'v': /* view file */ |
144 |
|
|
if (argv[i][2] != 'f') |
145 |
|
|
goto badopt; |
146 |
|
|
check(3,"s"); |
147 |
|
|
rval = viewfile(argv[++i], &ourview, NULL); |
148 |
|
|
if (rval < 0) { |
149 |
|
|
sprintf(errmsg, |
150 |
|
|
"cannot open view file \"%s\"", |
151 |
|
|
argv[i]); |
152 |
|
|
error(SYSTEM, errmsg); |
153 |
|
|
} else if (rval == 0) { |
154 |
|
|
sprintf(errmsg, |
155 |
|
|
"bad view file \"%s\"", |
156 |
|
|
argv[i]); |
157 |
|
|
error(USER, errmsg); |
158 |
|
|
} |
159 |
|
|
break; |
160 |
|
|
case 'p': /* pixel */ |
161 |
|
|
switch (argv[i][2]) { |
162 |
|
|
case 's': /* sample */ |
163 |
|
|
check(3,"i"); |
164 |
|
|
psample = atoi(argv[++i]); |
165 |
|
|
break; |
166 |
|
|
case 't': /* threshold */ |
167 |
|
|
check(3,"f"); |
168 |
|
|
maxdiff = atof(argv[++i]); |
169 |
|
|
break; |
170 |
|
|
case 'j': /* jitter */ |
171 |
|
|
check(3,"f"); |
172 |
|
|
dstrpix = atof(argv[++i]); |
173 |
|
|
break; |
174 |
|
|
case 'a': /* aspect */ |
175 |
|
|
check(3,"f"); |
176 |
|
|
pixaspect = atof(argv[++i]); |
177 |
|
|
break; |
178 |
|
|
case 'm': /* motion */ |
179 |
|
|
check(3,"f"); |
180 |
|
|
mblur = atof(argv[++i]); |
181 |
|
|
break; |
182 |
greg |
2.9 |
case 'd': /* aperture */ |
183 |
|
|
check(3,"f"); |
184 |
|
|
dblur = atof(argv[++i]); |
185 |
|
|
break; |
186 |
greg |
2.28 |
case 'R': /* standard RGB output */ |
187 |
|
|
if (strcmp(argv[i]+2, "RGB")) |
188 |
|
|
goto badopt; |
189 |
|
|
out_prims = stdprims; |
190 |
|
|
break; |
191 |
|
|
case 'X': /* XYZ output */ |
192 |
|
|
if (strcmp(argv[i]+2, "XYZ")) |
193 |
|
|
goto badopt; |
194 |
|
|
out_prims = xyzprims; |
195 |
|
|
break; |
196 |
|
|
case 'c': { /* chromaticities */ |
197 |
|
|
int j; |
198 |
|
|
check(3,"ffffffff"); |
199 |
|
|
rval = 0; |
200 |
|
|
for (j = 0; j < 8; j++) { |
201 |
|
|
our_prims[0][j] = atof(argv[++i]); |
202 |
|
|
rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001; |
203 |
|
|
} |
204 |
|
|
if (rval) { |
205 |
|
|
if (!colorprimsOK(our_prims)) |
206 |
|
|
error(USER, "illegal primary chromaticities"); |
207 |
|
|
out_prims = our_prims; |
208 |
|
|
} else |
209 |
|
|
out_prims = stdprims; |
210 |
|
|
} break; |
211 |
greg |
2.1 |
default: |
212 |
|
|
goto badopt; |
213 |
|
|
} |
214 |
|
|
break; |
215 |
|
|
case 'x': /* x resolution */ |
216 |
|
|
check(2,"i"); |
217 |
|
|
hresolu = atoi(argv[++i]); |
218 |
|
|
break; |
219 |
|
|
case 'y': /* y resolution */ |
220 |
|
|
check(2,"i"); |
221 |
|
|
vresolu = atoi(argv[++i]); |
222 |
|
|
break; |
223 |
|
|
case 'S': /* slave index */ |
224 |
|
|
check(2,"i"); |
225 |
|
|
seqstart = atoi(argv[++i]); |
226 |
|
|
break; |
227 |
|
|
case 'o': /* output file */ |
228 |
|
|
check(2,"s"); |
229 |
|
|
outfile = argv[++i]; |
230 |
|
|
break; |
231 |
|
|
case 'z': /* z file */ |
232 |
|
|
check(2,"s"); |
233 |
|
|
zfile = argv[++i]; |
234 |
|
|
break; |
235 |
|
|
case 'r': /* recover file */ |
236 |
|
|
if (argv[i][2] == 'o') { /* +output */ |
237 |
|
|
check(3,"s"); |
238 |
|
|
outfile = argv[i+1]; |
239 |
|
|
} else |
240 |
|
|
check(2,"s"); |
241 |
|
|
recover = argv[++i]; |
242 |
|
|
break; |
243 |
|
|
case 't': /* timer */ |
244 |
|
|
check(2,"i"); |
245 |
|
|
ralrm = atoi(argv[++i]); |
246 |
|
|
break; |
247 |
|
|
#ifdef PERSIST |
248 |
|
|
case 'P': /* persist file */ |
249 |
|
|
if (argv[i][2] == 'P') { |
250 |
|
|
check(3,"s"); |
251 |
|
|
persist = PARALLEL; |
252 |
|
|
} else { |
253 |
|
|
check(2,"s"); |
254 |
|
|
persist = PERSIST; |
255 |
|
|
} |
256 |
|
|
persistfile(argv[++i]); |
257 |
|
|
break; |
258 |
|
|
#endif |
259 |
|
|
case 'w': /* warnings */ |
260 |
|
|
rval = erract[WARNING].pf != NULL; |
261 |
schorsch |
2.18 |
check_bool(2,rval); |
262 |
greg |
2.1 |
if (rval) erract[WARNING].pf = wputs; |
263 |
|
|
else erract[WARNING].pf = NULL; |
264 |
|
|
break; |
265 |
|
|
case 'e': /* error file */ |
266 |
|
|
check(2,"s"); |
267 |
|
|
errfile = argv[++i]; |
268 |
|
|
break; |
269 |
|
|
default: |
270 |
|
|
goto badopt; |
271 |
|
|
} |
272 |
|
|
} |
273 |
greg |
2.30 |
/* set/check spectral sampling */ |
274 |
|
|
rval = setspectrsamp(CNDX, WLPART); |
275 |
|
|
if (rval < 0) |
276 |
|
|
error(USER, "unsupported spectral sampling"); |
277 |
|
|
|
278 |
greg |
2.1 |
err = setview(&ourview); /* set viewing parameters */ |
279 |
|
|
if (err != NULL) |
280 |
|
|
error(USER, err); |
281 |
|
|
/* initialize object types */ |
282 |
|
|
initotypes(); |
283 |
|
|
/* initialize urand */ |
284 |
greg |
2.12 |
if (rand_samp) { |
285 |
|
|
srandom((long)time(0)); |
286 |
|
|
initurand(0); |
287 |
|
|
} else { |
288 |
|
|
srandom(0L); |
289 |
|
|
initurand(2048); |
290 |
|
|
} |
291 |
greg |
2.1 |
/* set up signal handling */ |
292 |
|
|
sigdie(SIGINT, "Interrupt"); |
293 |
schorsch |
2.4 |
#ifdef SIGHUP |
294 |
greg |
2.1 |
sigdie(SIGHUP, "Hangup"); |
295 |
schorsch |
2.4 |
#endif |
296 |
greg |
2.1 |
sigdie(SIGTERM, "Terminate"); |
297 |
schorsch |
2.4 |
#ifdef SIGPIPE |
298 |
greg |
2.1 |
sigdie(SIGPIPE, "Broken pipe"); |
299 |
schorsch |
2.4 |
#endif |
300 |
|
|
#ifdef SIGALRM |
301 |
greg |
2.1 |
sigdie(SIGALRM, "Alarm clock"); |
302 |
schorsch |
2.4 |
#endif |
303 |
greg |
2.1 |
#ifdef SIGXCPU |
304 |
|
|
sigdie(SIGXCPU, "CPU limit exceeded"); |
305 |
|
|
sigdie(SIGXFSZ, "File size exceeded"); |
306 |
|
|
#endif |
307 |
|
|
/* open error file */ |
308 |
|
|
if (errfile != NULL) { |
309 |
|
|
if (freopen(errfile, "a", stderr) == NULL) |
310 |
|
|
quit(2); |
311 |
|
|
fprintf(stderr, "**************\n*** PID %5d: ", |
312 |
|
|
getpid()); |
313 |
|
|
printargs(argc, argv, stderr); |
314 |
|
|
putc('\n', stderr); |
315 |
|
|
fflush(stderr); |
316 |
|
|
} |
317 |
|
|
#ifdef NICE |
318 |
|
|
nice(NICE); /* lower priority */ |
319 |
|
|
#endif |
320 |
|
|
/* get octree */ |
321 |
|
|
if (i == argc) |
322 |
|
|
octname = NULL; |
323 |
|
|
else if (i == argc-1) |
324 |
|
|
octname = argv[i]; |
325 |
|
|
else |
326 |
|
|
goto badopt; |
327 |
|
|
if (seqstart > 0 && octname == NULL) |
328 |
|
|
error(USER, "missing octree argument"); |
329 |
|
|
/* set up output */ |
330 |
|
|
#ifdef PERSIST |
331 |
|
|
if (persist) { |
332 |
|
|
if (recover != NULL) |
333 |
|
|
error(USER, "persist option used with recover file"); |
334 |
|
|
if (seqstart <= 0) |
335 |
|
|
error(USER, "persist option only for sequences"); |
336 |
|
|
if (outfile == NULL) |
337 |
|
|
duped1 = dup(fileno(stdout)); /* don't lose our output */ |
338 |
|
|
openheader(); |
339 |
|
|
} else |
340 |
|
|
#endif |
341 |
|
|
if (outfile != NULL) |
342 |
|
|
openheader(); |
343 |
schorsch |
2.3 |
SET_FILE_BINARY(stdout); |
344 |
greg |
2.1 |
if (octname == NULL) |
345 |
schorsch |
2.3 |
SET_FILE_BINARY(stdin); |
346 |
greg |
2.1 |
readoct(octname, loadflags, &thescene, NULL); |
347 |
|
|
nsceneobjs = nobjects; |
348 |
|
|
|
349 |
|
|
if (loadflags & IO_INFO) { /* print header */ |
350 |
|
|
printargs(i, argv, stdout); |
351 |
|
|
printf("SOFTWARE= %s\n", VersionID); |
352 |
|
|
} |
353 |
greg |
2.16 |
|
354 |
|
|
ray_init_pmap(); /* PMAP: set up & load photon maps */ |
355 |
greg |
2.1 |
|
356 |
|
|
marksources(); /* find and mark sources */ |
357 |
|
|
|
358 |
|
|
setambient(); /* initialize ambient calculation */ |
359 |
greg |
2.16 |
|
360 |
greg |
2.20 |
fflush(stdout); /* in case we're duplicating header */ |
361 |
|
|
|
362 |
greg |
2.1 |
#ifdef PERSIST |
363 |
|
|
if (persist) { |
364 |
|
|
if (outfile == NULL) { /* reconnect stdout */ |
365 |
|
|
dup2(duped1, fileno(stdout)); |
366 |
|
|
close(duped1); |
367 |
|
|
} |
368 |
|
|
if (persist == PARALLEL) { /* multiprocessing */ |
369 |
|
|
preload_objs(); /* preload scene */ |
370 |
|
|
shm_boundary = (char *)malloc(16); |
371 |
|
|
strcpy(shm_boundary, "SHM_BOUNDARY"); |
372 |
|
|
while ((rval=fork()) == 0) { /* keep on forkin' */ |
373 |
|
|
pflock(1); |
374 |
|
|
pfhold(); |
375 |
|
|
tstart = time((time_t *)NULL); |
376 |
greg |
2.13 |
ambsync(); /* load new values */ |
377 |
greg |
2.1 |
} |
378 |
|
|
if (rval < 0) |
379 |
|
|
error(SYSTEM, "cannot fork child for persist function"); |
380 |
greg |
2.13 |
pfdetach(); /* parent will run then exit */ |
381 |
greg |
2.1 |
} |
382 |
|
|
} |
383 |
|
|
runagain: |
384 |
schorsch |
2.7 |
if (persist) { |
385 |
greg |
2.1 |
if (outfile == NULL) /* if out to stdout */ |
386 |
|
|
dupheader(); /* send header */ |
387 |
|
|
else /* if out to file */ |
388 |
|
|
duped1 = dup(fileno(stdout)); /* hang onto pipe */ |
389 |
schorsch |
2.7 |
} |
390 |
greg |
2.1 |
#endif |
391 |
|
|
/* batch render picture(s) */ |
392 |
|
|
rpict(seqstart, outfile, zfile, recover); |
393 |
|
|
/* flush ambient file */ |
394 |
|
|
ambsync(); |
395 |
|
|
#ifdef PERSIST |
396 |
|
|
if (persist == PERSIST) { /* first run-through */ |
397 |
|
|
if ((rval=fork()) == 0) { /* child loops until killed */ |
398 |
|
|
pflock(1); |
399 |
|
|
persist = PCHILD; |
400 |
|
|
} else { /* original process exits */ |
401 |
|
|
if (rval < 0) |
402 |
|
|
error(SYSTEM, "cannot fork child for persist function"); |
403 |
|
|
pfdetach(); /* parent exits */ |
404 |
|
|
} |
405 |
|
|
} |
406 |
|
|
if (persist == PCHILD) { /* wait for a signal then go again */ |
407 |
|
|
if (outfile != NULL) |
408 |
|
|
close(duped1); /* release output handle */ |
409 |
|
|
pfhold(); |
410 |
|
|
tstart = time((time_t *)NULL); /* reinitialize */ |
411 |
|
|
raynum = nrays = 0; |
412 |
|
|
goto runagain; |
413 |
|
|
} |
414 |
|
|
#endif |
415 |
greg |
2.16 |
|
416 |
|
|
|
417 |
|
|
ray_done_pmap(); /* PMAP: free photon maps */ |
418 |
|
|
|
419 |
greg |
2.1 |
quit(0); |
420 |
|
|
|
421 |
|
|
badopt: |
422 |
|
|
sprintf(errmsg, "command line error at '%s'", argv[i]); |
423 |
|
|
error(USER, errmsg); |
424 |
schorsch |
2.8 |
return 1; /* pro forma return */ |
425 |
greg |
2.1 |
|
426 |
|
|
#undef check |
427 |
schorsch |
2.18 |
#undef check_bool |
428 |
greg |
2.1 |
} |
429 |
|
|
|
430 |
|
|
|
431 |
|
|
void |
432 |
schorsch |
2.8 |
wputs( /* warning output function */ |
433 |
greg |
2.26 |
const char *s |
434 |
schorsch |
2.8 |
) |
435 |
greg |
2.1 |
{ |
436 |
|
|
int lasterrno = errno; |
437 |
|
|
eputs(s); |
438 |
|
|
errno = lasterrno; |
439 |
|
|
} |
440 |
|
|
|
441 |
|
|
|
442 |
|
|
void |
443 |
schorsch |
2.8 |
eputs( /* put string to stderr */ |
444 |
greg |
2.26 |
const char *s |
445 |
schorsch |
2.8 |
) |
446 |
greg |
2.1 |
{ |
447 |
|
|
static int midline = 0; |
448 |
|
|
|
449 |
|
|
if (!*s) |
450 |
|
|
return; |
451 |
|
|
if (!midline++) { |
452 |
|
|
fputs(progname, stderr); |
453 |
|
|
fputs(": ", stderr); |
454 |
|
|
} |
455 |
|
|
fputs(s, stderr); |
456 |
|
|
if (s[strlen(s)-1] == '\n') { |
457 |
|
|
fflush(stderr); |
458 |
|
|
midline = 0; |
459 |
|
|
} |
460 |
|
|
} |
461 |
|
|
|
462 |
|
|
|
463 |
schorsch |
2.8 |
static void |
464 |
|
|
onsig( /* fatal signal */ |
465 |
|
|
int signo |
466 |
|
|
) |
467 |
greg |
2.1 |
{ |
468 |
|
|
static int gotsig = 0; |
469 |
|
|
|
470 |
|
|
if (gotsig++) /* two signals and we're gone! */ |
471 |
|
|
_exit(signo); |
472 |
|
|
|
473 |
schorsch |
2.4 |
#ifdef SIGALRM /* XXX how critical is this? */ |
474 |
greg |
2.1 |
alarm(15); /* allow 15 seconds to clean up */ |
475 |
|
|
signal(SIGALRM, SIG_DFL); /* make certain we do die */ |
476 |
schorsch |
2.4 |
#endif |
477 |
greg |
2.1 |
eputs("signal - "); |
478 |
|
|
eputs(sigerr[signo]); |
479 |
|
|
eputs("\n"); |
480 |
|
|
quit(3); |
481 |
|
|
} |
482 |
|
|
|
483 |
|
|
|
484 |
schorsch |
2.8 |
static void |
485 |
|
|
sigdie( /* set fatal signal */ |
486 |
|
|
int signo, |
487 |
|
|
char *msg |
488 |
|
|
) |
489 |
greg |
2.1 |
{ |
490 |
|
|
if (signal(signo, onsig) == SIG_IGN) |
491 |
|
|
signal(signo, SIG_IGN); |
492 |
|
|
sigerr[signo] = msg; |
493 |
|
|
} |
494 |
|
|
|
495 |
|
|
|
496 |
schorsch |
2.8 |
static void |
497 |
|
|
printdefaults(void) /* print default values to stdout */ |
498 |
greg |
2.1 |
{ |
499 |
|
|
printf("-vt%c\t\t\t\t# view type %s\n", ourview.type, |
500 |
|
|
ourview.type==VT_PER ? "perspective" : |
501 |
|
|
ourview.type==VT_PAR ? "parallel" : |
502 |
|
|
ourview.type==VT_HEM ? "hemispherical" : |
503 |
|
|
ourview.type==VT_ANG ? "angular" : |
504 |
|
|
ourview.type==VT_CYL ? "cylindrical" : |
505 |
greg |
2.14 |
ourview.type==VT_PLS ? "planisphere" : |
506 |
greg |
2.1 |
"unknown"); |
507 |
|
|
printf("-vp %f %f %f\t# view point\n", |
508 |
|
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
509 |
|
|
printf("-vd %f %f %f\t# view direction\n", |
510 |
|
|
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
511 |
|
|
printf("-vu %f %f %f\t# view up\n", |
512 |
|
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
513 |
|
|
printf("-vh %f\t\t\t# view horizontal size\n", ourview.horiz); |
514 |
|
|
printf("-vv %f\t\t\t# view vertical size\n", ourview.vert); |
515 |
|
|
printf("-vo %f\t\t\t# view fore clipping plane\n", ourview.vfore); |
516 |
|
|
printf("-va %f\t\t\t# view aft clipping plane\n", ourview.vaft); |
517 |
|
|
printf("-vs %f\t\t\t# view shift\n", ourview.hoff); |
518 |
|
|
printf("-vl %f\t\t\t# view lift\n", ourview.voff); |
519 |
|
|
printf("-x %-9d\t\t\t# x resolution\n", hresolu); |
520 |
|
|
printf("-y %-9d\t\t\t# y resolution\n", vresolu); |
521 |
greg |
2.28 |
if (out_prims == stdprims) |
522 |
|
|
printf("-pRGB\t\t\t\t# standard RGB color output\n"); |
523 |
|
|
else if (out_prims == xyzprims) |
524 |
|
|
printf("-pXYZ\t\t\t\t# CIE XYZ color output\n"); |
525 |
|
|
else if (out_prims != NULL) |
526 |
|
|
printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n", |
527 |
|
|
out_prims[RED][0], out_prims[RED][1], |
528 |
|
|
out_prims[GRN][0], out_prims[GRN][1], |
529 |
|
|
out_prims[BLU][0], out_prims[BLU][1], |
530 |
|
|
out_prims[WHT][0], out_prims[WHT][1]); |
531 |
greg |
2.1 |
printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect); |
532 |
|
|
printf("-pj %f\t\t\t# pixel jitter\n", dstrpix); |
533 |
|
|
printf("-pm %f\t\t\t# pixel motion\n", mblur); |
534 |
greg |
2.9 |
printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur); |
535 |
greg |
2.1 |
printf("-ps %-9d\t\t\t# pixel sample\n", psample); |
536 |
|
|
printf("-pt %f\t\t\t# pixel threshold\n", maxdiff); |
537 |
|
|
printf("-t %-9d\t\t\t# time between reports\n", ralrm); |
538 |
|
|
printf(erract[WARNING].pf != NULL ? |
539 |
|
|
"-w+\t\t\t\t# warning messages on\n" : |
540 |
|
|
"-w-\t\t\t\t# warning messages off\n"); |
541 |
|
|
print_rdefaults(); |
542 |
|
|
} |