1 |
– |
/* Copyright (c) 1999 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Radiance holodeck picture generator |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include <string.h> |
9 |
+ |
|
10 |
|
#include "rholo.h" |
11 |
|
#include "view.h" |
13 |
– |
#include "resolu.h" |
12 |
|
|
13 |
|
char *progname; /* our program name */ |
14 |
|
char *hdkfile; /* holodeck file name */ |
15 |
+ |
char gargc; /* global argc */ |
16 |
+ |
char **gargv; /* global argv */ |
17 |
|
|
18 |
|
VIEW myview = STDVIEW; /* current output view */ |
19 |
|
int xres = 512, yres = 512; /* max. horizontal and vertical resolution */ |
37 |
|
{ |
38 |
|
int i, rval; |
39 |
|
|
40 |
+ |
gargc = argc; gargv = argv; |
41 |
|
progname = argv[0]; /* get arguments */ |
42 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) { |
43 |
|
rval = getviewopt(&myview, argc-i, argv+i); |
56 |
|
pixaspect = atof(argv[++i]); |
57 |
|
else if (argv[i][2] == 'e') { |
58 |
|
expval = atof(argv[++i]); |
59 |
< |
if (argv[i][0] == '-' | argv[i][0] == '+') |
59 |
> |
if ((argv[i][0] == '-') | (argv[i][0] == '+')) |
60 |
|
expval = pow(2., expval); |
61 |
|
} else |
62 |
|
goto userr; |
145 |
|
/* render image */ |
146 |
|
if (blist.nb > 0) { |
147 |
|
render_frame(blist.bl, blist.nb); |
148 |
< |
free((char *)blist.bl); |
148 |
> |
free((void *)blist.bl); |
149 |
|
} else { |
150 |
|
sprintf(errmsg, "no section visible in frame %d", fn); |
151 |
|
error(WARNING, errmsg); |
169 |
|
register PACKHEAD *bl; |
170 |
|
int nb; |
171 |
|
{ |
172 |
< |
extern int pixBeam(); |
172 |
> |
extern void pixBeam(); |
173 |
|
register HDBEAMI *bil; |
174 |
|
register int i; |
175 |
|
|
182 |
|
} |
183 |
|
hdloadbeams(bil, nb, pixBeam); |
184 |
|
pixFinish(randfrac); |
185 |
< |
free((char *)bil); |
185 |
> |
free((void *)bil); |
186 |
|
} |
187 |
|
|
188 |
|
|
206 |
|
/* write header */ |
207 |
|
newheader("RADIANCE", stdout); |
208 |
|
printf("SOFTWARE= %s\n", VersionID); |
209 |
< |
printf("%s %s\n", progname, hdkfile); |
209 |
> |
printargs(gargc, gargv, stdout); |
210 |
|
if (fn) |
211 |
|
printf("FRAME=%d\n", fn); |
212 |
|
fputs(VIEWSTR, stdout); |
213 |
|
fprintview(&myview, stdout); |
214 |
|
fputc('\n', stdout); |
215 |
< |
if (pa < 0.99 | pa > 1.01) |
215 |
> |
if ((pa < 0.99) | (pa > 1.01)) |
216 |
|
fputaspect(pa, stdout); |
217 |
< |
if (expval < 0.99 | expval > 1.01) |
217 |
> |
if ((expval < 0.99) | (expval > 1.01)) |
218 |
|
fputexpos(expval, stdout); |
219 |
|
fputformat(COLRFMT, stdout); |
220 |
|
fputc('\n', stdout); |
221 |
|
/* write resolution (standard order) */ |
222 |
|
fprtresolu(hres, vres, stdout); |
223 |
|
/* prepare image buffers */ |
224 |
< |
bzero((char *)mypixel, hres*vres*sizeof(COLOR)); |
225 |
< |
bzero((char *)myweight, hres*vres*sizeof(float)); |
226 |
< |
bzero((char *)mydepth, hres*vres*sizeof(float)); |
224 |
> |
memset((char *)mypixel, '\0', hres*vres*sizeof(COLOR)); |
225 |
> |
memset((char *)myweight, '\0', hres*vres*sizeof(float)); |
226 |
> |
memset((char *)mydepth, '\0', hres*vres*sizeof(float)); |
227 |
|
} |
228 |
|
|
229 |
|
|
231 |
|
endpicture() /* finish and write out pixels */ |
232 |
|
{ |
233 |
|
int lastr = -1, nunrend = 0; |
234 |
< |
int4 lastp, lastrp; |
235 |
< |
register int4 p; |
234 |
> |
int32 lastp, lastrp; |
235 |
> |
register int32 p; |
236 |
|
register double d; |
237 |
|
/* compute final pixel values */ |
238 |
|
for (p = hres*vres; p--; ) { |
239 |
|
if (myweight[p] <= FTINY) { |
240 |
< |
if (lastr >= 0) |
240 |
> |
if (lastr >= 0) { |
241 |
|
if (p/hres == lastp/hres) |
242 |
|
copycolor(mypixel[p], mypixel[lastp]); |
243 |
|
else |
244 |
|
copycolor(mypixel[p], mypixel[lastrp]); |
245 |
+ |
} |
246 |
|
nunrend++; |
247 |
|
continue; |
248 |
|
} |
263 |
|
|
264 |
|
initialize() /* initialize holodeck and buffers */ |
265 |
|
{ |
264 |
– |
extern long ftell(); |
266 |
|
int fd; |
267 |
|
FILE *fp; |
268 |
|
int n; |
269 |
< |
int4 nextloc; |
269 |
> |
int32 nextloc; |
270 |
|
/* open holodeck file */ |
271 |
|
if ((fp = fopen(hdkfile, "r")) == NULL) { |
272 |
|
sprintf(errmsg, "cannot open \"%s\" for reading", hdkfile); |
284 |
|
fd = dup(fileno(fp)); /* dup file descriptor */ |
285 |
|
fclose(fp); /* done with stdio */ |
286 |
|
for (n = 0; nextloc > 0L; n++) { /* initialize each section */ |
287 |
< |
lseek(fd, (long)nextloc, 0); |
287 |
> |
lseek(fd, (off_t)nextloc, 0); |
288 |
|
read(fd, (char *)&nextloc, sizeof(nextloc)); |
289 |
|
hdinit(fd, NULL); |
290 |
|
} |
292 |
|
mypixel = (COLOR *)bmalloc(xres*yres*sizeof(COLOR)); |
293 |
|
myweight = (float *)bmalloc(xres*yres*sizeof(float)); |
294 |
|
mydepth = (float *)bmalloc(xres*yres*sizeof(float)); |
295 |
< |
if (mypixel == NULL | myweight == NULL | mydepth == NULL) |
295 |
> |
if ((mypixel == NULL) | (myweight == NULL) | (mydepth == NULL)) |
296 |
|
error(SYSTEM, "out of memory in initialize"); |
297 |
|
} |
298 |
|
|
299 |
|
|
300 |
+ |
void |
301 |
|
eputs(s) /* put error message to stderr */ |
302 |
|
register char *s; |
303 |
|
{ |