6 |
|
*/ |
7 |
|
|
8 |
|
#include <string.h> |
9 |
< |
|
9 |
> |
#include "platform.h" |
10 |
> |
#include "rterror.h" |
11 |
|
#include "rholo.h" |
11 |
– |
#include "view.h" |
12 |
|
|
13 |
– |
char *progname; /* our program name */ |
13 |
|
char *hdkfile; /* holodeck file name */ |
14 |
|
char gargc; /* global argc */ |
15 |
|
char **gargv; /* global argv */ |
29 |
|
|
30 |
|
extern int nowarn; /* turn warnings off? */ |
31 |
|
|
32 |
+ |
static void dopicture(int fn); |
33 |
+ |
static void render_frame(PACKHEAD *bl, int nb); |
34 |
+ |
static void startpicture(int fn); |
35 |
+ |
static int endpicture(void); |
36 |
+ |
static void initialize(void); |
37 |
+ |
/* from rhpict2.c */ |
38 |
+ |
extern void pixFinish(double ransamp); |
39 |
+ |
extern void pixBeam(BEAM *bp, HDBEAMI *hb); |
40 |
|
|
41 |
< |
main(argc, argv) |
42 |
< |
int argc; |
43 |
< |
char *argv[]; |
41 |
> |
|
42 |
> |
int |
43 |
> |
main( |
44 |
> |
int argc, |
45 |
> |
char *argv[] |
46 |
> |
) |
47 |
|
{ |
48 |
|
int i, rval; |
49 |
|
|
50 |
|
gargc = argc; gargv = argv; |
51 |
< |
progname = argv[0]; /* get arguments */ |
51 |
> |
fixargv0(argv[0]); /* get arguments */ |
52 |
|
for (i = 1; i < argc && argv[i][0] == '-'; i++) { |
53 |
|
rval = getviewopt(&myview, argc-i, argv+i); |
54 |
|
if (rval >= 0) { /* view option */ |
66 |
|
pixaspect = atof(argv[++i]); |
67 |
|
else if (argv[i][2] == 'e') { |
68 |
|
expval = atof(argv[++i]); |
69 |
< |
if (argv[i][0] == '-' | argv[i][0] == '+') |
69 |
> |
if ((argv[i][0] == '-') | (argv[i][0] == '+')) |
70 |
|
expval = pow(2., expval); |
71 |
|
} else |
72 |
|
goto userr; |
134 |
|
"Usage: %s [-w][-r rf][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", |
135 |
|
progname); |
136 |
|
quit(1); |
137 |
+ |
return 1; /* pro forma return */ |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
< |
dopicture(fn) /* render view from holodeck */ |
142 |
< |
int fn; |
141 |
> |
static void |
142 |
> |
dopicture( /* render view from holodeck */ |
143 |
> |
int fn |
144 |
> |
) |
145 |
|
{ |
146 |
|
char *err; |
147 |
|
int rval; |
178 |
|
} |
179 |
|
|
180 |
|
|
181 |
< |
render_frame(bl, nb) /* render frame from beam values */ |
182 |
< |
register PACKHEAD *bl; |
183 |
< |
int nb; |
181 |
> |
static void |
182 |
> |
render_frame( /* render frame from beam values */ |
183 |
> |
PACKHEAD *bl, |
184 |
> |
int nb |
185 |
> |
) |
186 |
|
{ |
187 |
< |
extern void pixBeam(); |
188 |
< |
register HDBEAMI *bil; |
174 |
< |
register int i; |
187 |
> |
HDBEAMI *bil; |
188 |
> |
int i; |
189 |
|
|
190 |
|
if (nb <= 0) return; |
191 |
|
if ((bil = (HDBEAMI *)malloc(nb*sizeof(HDBEAMI))) == NULL) |
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
< |
startpicture(fn) /* initialize picture for rendering & output */ |
204 |
< |
int fn; |
203 |
> |
static void |
204 |
> |
startpicture( /* initialize picture for rendering & output */ |
205 |
> |
int fn |
206 |
> |
) |
207 |
|
{ |
208 |
|
extern char VersionID[]; |
209 |
|
double pa = pixaspect; |
214 |
|
/* prepare output */ |
215 |
|
if (outspec != NULL) { |
216 |
|
sprintf(fname, outspec, fn); |
217 |
< |
if (freopen(fname, "w", stdout) == NULL) { |
217 |
> |
if (freopen(fname, "wb", stdout) == NULL) { |
218 |
|
sprintf(errmsg, "cannot open output \"%s\"", fname); |
219 |
|
error(SYSTEM, errmsg); |
220 |
|
} |
228 |
|
fputs(VIEWSTR, stdout); |
229 |
|
fprintview(&myview, stdout); |
230 |
|
fputc('\n', stdout); |
231 |
< |
if (pa < 0.99 | pa > 1.01) |
231 |
> |
if ((pa < 0.995) | (pa > 1.005)) |
232 |
|
fputaspect(pa, stdout); |
233 |
< |
if (expval < 0.99 | expval > 1.01) |
233 |
> |
if ((expval < 0.99) | (expval > 1.01)) |
234 |
|
fputexpos(expval, stdout); |
235 |
|
fputformat(COLRFMT, stdout); |
236 |
|
fputc('\n', stdout); |
243 |
|
} |
244 |
|
|
245 |
|
|
246 |
< |
int |
247 |
< |
endpicture() /* finish and write out pixels */ |
246 |
> |
static int |
247 |
> |
endpicture(void) /* finish and write out pixels */ |
248 |
|
{ |
249 |
|
int lastr = -1, nunrend = 0; |
250 |
|
int32 lastp, lastrp; |
251 |
< |
register int32 p; |
252 |
< |
register double d; |
251 |
> |
int32 p; |
252 |
> |
double d; |
253 |
|
/* compute final pixel values */ |
254 |
|
for (p = hres*vres; p--; ) { |
255 |
|
if (myweight[p] <= FTINY) { |
277 |
|
} |
278 |
|
|
279 |
|
|
280 |
< |
initialize() /* initialize holodeck and buffers */ |
280 |
> |
static void |
281 |
> |
initialize(void) /* initialize holodeck and buffers */ |
282 |
|
{ |
283 |
|
int fd; |
284 |
|
FILE *fp; |
285 |
|
int n; |
286 |
< |
int32 nextloc; |
286 |
> |
off_t nextloc; |
287 |
|
/* open holodeck file */ |
288 |
< |
if ((fp = fopen(hdkfile, "r")) == NULL) { |
288 |
> |
if ((fp = fopen(hdkfile, "rb")) == NULL) { |
289 |
|
sprintf(errmsg, "cannot open \"%s\" for reading", hdkfile); |
290 |
|
error(SYSTEM, errmsg); |
291 |
|
} |
301 |
|
fd = dup(fileno(fp)); /* dup file descriptor */ |
302 |
|
fclose(fp); /* done with stdio */ |
303 |
|
for (n = 0; nextloc > 0L; n++) { /* initialize each section */ |
304 |
< |
lseek(fd, (off_t)nextloc, 0); |
304 |
> |
lseek(fd, nextloc, SEEK_SET); |
305 |
|
read(fd, (char *)&nextloc, sizeof(nextloc)); |
306 |
|
hdinit(fd, NULL); |
307 |
|
} |
309 |
|
mypixel = (COLOR *)bmalloc(xres*yres*sizeof(COLOR)); |
310 |
|
myweight = (float *)bmalloc(xres*yres*sizeof(float)); |
311 |
|
mydepth = (float *)bmalloc(xres*yres*sizeof(float)); |
312 |
< |
if (mypixel == NULL | myweight == NULL | mydepth == NULL) |
312 |
> |
if ((mypixel == NULL) | (myweight == NULL) | (mydepth == NULL)) |
313 |
|
error(SYSTEM, "out of memory in initialize"); |
314 |
|
} |
315 |
|
|
316 |
|
|
317 |
|
void |
318 |
< |
eputs(s) /* put error message to stderr */ |
302 |
< |
register char *s; |
318 |
> |
eputs(const char *s) /* put error message to stderr */ |
319 |
|
{ |
320 |
|
static int midline = 0; |
321 |
|
|