| 7 |
|
|
| 8 |
|
#include "copyright.h" |
| 9 |
|
|
| 10 |
< |
#include "ray.h" |
| 10 |
> |
#include <signal.h> |
| 11 |
> |
#include <time.h> |
| 12 |
|
|
| 13 |
+ |
#include "platform.h" |
| 14 |
+ |
#include "ray.h" |
| 15 |
|
#include "source.h" |
| 13 |
– |
|
| 16 |
|
#include "ambient.h" |
| 17 |
< |
|
| 17 |
> |
#include "rpaint.h" |
| 18 |
|
#include "random.h" |
| 17 |
– |
|
| 19 |
|
#include "paths.h" |
| 19 |
– |
|
| 20 |
– |
#include <signal.h> |
| 21 |
– |
|
| 20 |
|
#include "view.h" |
| 21 |
|
|
| 22 |
|
char *progname; /* argv[0] */ |
| 43 |
|
extern int psample; /* pixel sample size */ |
| 44 |
|
extern double maxdiff; /* max. sample difference */ |
| 45 |
|
|
| 46 |
< |
void onsig(); |
| 47 |
< |
void sigdie(); |
| 48 |
< |
void printdefaults(); |
| 46 |
> |
static void onsig(int signo); |
| 47 |
> |
static void sigdie(int signo, char *msg); |
| 48 |
> |
static void printdefaults(void); |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
int |
| 52 |
< |
main(argc, argv) |
| 55 |
< |
int argc; |
| 56 |
< |
char *argv[]; |
| 52 |
> |
main(int argc, char *argv[]) |
| 53 |
|
{ |
| 54 |
|
#define check(ol,al) if (argv[i][ol] || \ |
| 55 |
|
badarg(argc-i-1,argv+i+1,al)) \ |
| 169 |
|
/* initialize object types */ |
| 170 |
|
initotypes(); |
| 171 |
|
/* initialize urand */ |
| 172 |
< |
initurand(2048); |
| 172 |
> |
if (rand_samp) { |
| 173 |
> |
srandom((long)time(0)); |
| 174 |
> |
initurand(0); |
| 175 |
> |
} else { |
| 176 |
> |
srandom(0L); |
| 177 |
> |
initurand(2048); |
| 178 |
> |
} |
| 179 |
|
/* set up signal handling */ |
| 180 |
|
sigdie(SIGINT, "Interrupt"); |
| 181 |
|
sigdie(SIGHUP, "Hangup"); |
| 209 |
|
if (octname == NULL) |
| 210 |
|
error(USER, "missing octree argument"); |
| 211 |
|
/* set up output */ |
| 212 |
< |
#ifdef MSDOS |
| 211 |
< |
setmode(fileno(stdout), O_BINARY); |
| 212 |
< |
#endif |
| 212 |
> |
SET_FILE_BINARY(stdout); |
| 213 |
|
readoct(octname, ~(IO_FILES|IO_INFO), &thescene, NULL); |
| 214 |
|
nsceneobjs = nobjects; |
| 215 |
|
|
| 226 |
|
badopt: |
| 227 |
|
sprintf(errmsg, "command line error at '%s'", argv[i]); |
| 228 |
|
error(USER, errmsg); |
| 229 |
+ |
return 1; /* pro forma return */ |
| 230 |
|
|
| 231 |
|
#undef check |
| 232 |
|
#undef bool |
| 234 |
|
|
| 235 |
|
|
| 236 |
|
void |
| 237 |
< |
wputs(s) /* warning output function */ |
| 238 |
< |
char *s; |
| 237 |
> |
wputs( /* warning output function */ |
| 238 |
> |
char *s |
| 239 |
> |
) |
| 240 |
|
{ |
| 241 |
|
int lasterrno = errno; |
| 242 |
|
eputs(s); |
| 245 |
|
|
| 246 |
|
|
| 247 |
|
void |
| 248 |
< |
eputs(s) /* put string to stderr */ |
| 249 |
< |
register char *s; |
| 248 |
> |
eputs( /* put string to stderr */ |
| 249 |
> |
register char *s |
| 250 |
> |
) |
| 251 |
|
{ |
| 252 |
|
static int midline = 0; |
| 253 |
|
|
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
|
| 268 |
< |
void |
| 269 |
< |
onsig(signo) /* fatal signal */ |
| 270 |
< |
int signo; |
| 268 |
> |
static void |
| 269 |
> |
onsig( /* fatal signal */ |
| 270 |
> |
int signo |
| 271 |
> |
) |
| 272 |
|
{ |
| 273 |
|
static int gotsig = 0; |
| 274 |
|
|
| 284 |
|
} |
| 285 |
|
|
| 286 |
|
|
| 287 |
< |
void |
| 288 |
< |
sigdie(signo, msg) /* set fatal signal */ |
| 289 |
< |
int signo; |
| 290 |
< |
char *msg; |
| 287 |
> |
static void |
| 288 |
> |
sigdie( /* set fatal signal */ |
| 289 |
> |
int signo, |
| 290 |
> |
char *msg |
| 291 |
> |
) |
| 292 |
|
{ |
| 293 |
|
if (signal(signo, onsig) == SIG_IGN) |
| 294 |
|
signal(signo, SIG_IGN); |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
|
| 299 |
< |
void |
| 300 |
< |
printdefaults() /* print default values to stdout */ |
| 299 |
> |
static void |
| 300 |
> |
printdefaults(void) /* print default values to stdout */ |
| 301 |
|
{ |
| 297 |
– |
register char *cp; |
| 298 |
– |
|
| 302 |
|
printf(greyscale ? "-b+\t\t\t\t# greyscale on\n" : |
| 303 |
|
"-b-\t\t\t\t# greyscale off\n"); |
| 304 |
|
printf("-vt%c\t\t\t\t# view type %s\n", ourview.type, |
| 307 |
|
ourview.type==VT_HEM ? "hemispherical" : |
| 308 |
|
ourview.type==VT_ANG ? "angular" : |
| 309 |
|
ourview.type==VT_CYL ? "cylindrical" : |
| 310 |
+ |
ourview.type==VT_PLS ? "planisphere" : |
| 311 |
|
"unknown"); |
| 312 |
|
printf("-vp %f %f %f\t# view point\n", |
| 313 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |