--- ray/src/hd/rhpict.c 2003/06/20 00:25:49 3.10 +++ ray/src/hd/rhpict.c 2004/01/01 11:21:55 3.17 @@ -1,10 +1,14 @@ #ifndef lint -static const char RCSid[] = "$Id: rhpict.c,v 3.10 2003/06/20 00:25:49 greg Exp $"; +static const char RCSid[] = "$Id: rhpict.c,v 3.17 2004/01/01 11:21:55 schorsch Exp $"; #endif /* * Radiance holodeck picture generator */ +#include + +#include "platform.h" +#include "rterror.h" #include "rholo.h" #include "view.h" @@ -28,10 +32,21 @@ int hres, vres; /* current horizontal and vertical re extern int nowarn; /* turn warnings off? */ +static void dopicture(int fn); +static void render_frame(PACKHEAD *bl, int nb); +static void startpicture(int fn); +static int endpicture(void); +static void initialize(void); + /* from rhpict2.c */ +extern void pixFinish(double ransamp); +extern void pixBeam(BEAM *bp, HDBEAMI *hb); -main(argc, argv) -int argc; -char *argv[]; + +int +main( +int argc, +char *argv[] +) { int i, rval; @@ -54,7 +69,7 @@ char *argv[]; pixaspect = atof(argv[++i]); else if (argv[i][2] == 'e') { expval = atof(argv[++i]); - if (argv[i][0] == '-' | argv[i][0] == '+') + if ((argv[i][0] == '-') | (argv[i][0] == '+')) expval = pow(2., expval); } else goto userr; @@ -122,11 +137,14 @@ userr: "Usage: %s [-w][-r rf][-pa pa][-pe ex][-x hr][-y vr][-S stfn][-o outp][view] input.hdk\n", progname); quit(1); + return 1; /* pro forma return */ } -dopicture(fn) /* render view from holodeck */ -int fn; +static void +dopicture( /* render view from holodeck */ + int fn +) { char *err; int rval; @@ -163,11 +181,12 @@ int fn; } -render_frame(bl, nb) /* render frame from beam values */ -register PACKHEAD *bl; -int nb; +static void +render_frame( /* render frame from beam values */ + register PACKHEAD *bl, + int nb +) { - extern int pixBeam(); register HDBEAMI *bil; register int i; @@ -184,8 +203,10 @@ int nb; } -startpicture(fn) /* initialize picture for rendering & output */ -int fn; +static void +startpicture( /* initialize picture for rendering & output */ + int fn +) { extern char VersionID[]; double pa = pixaspect; @@ -210,23 +231,23 @@ int fn; fputs(VIEWSTR, stdout); fprintview(&myview, stdout); fputc('\n', stdout); - if (pa < 0.99 | pa > 1.01) + if ((pa < 0.99) | (pa > 1.01)) fputaspect(pa, stdout); - if (expval < 0.99 | expval > 1.01) + if ((expval < 0.99) | (expval > 1.01)) fputexpos(expval, stdout); fputformat(COLRFMT, stdout); fputc('\n', stdout); /* write resolution (standard order) */ fprtresolu(hres, vres, stdout); /* prepare image buffers */ - bzero((char *)mypixel, hres*vres*sizeof(COLOR)); - bzero((char *)myweight, hres*vres*sizeof(float)); - bzero((char *)mydepth, hres*vres*sizeof(float)); + memset((char *)mypixel, '\0', hres*vres*sizeof(COLOR)); + memset((char *)myweight, '\0', hres*vres*sizeof(float)); + memset((char *)mydepth, '\0', hres*vres*sizeof(float)); } -int -endpicture() /* finish and write out pixels */ +static int +endpicture(void) /* finish and write out pixels */ { int lastr = -1, nunrend = 0; int32 lastp, lastrp; @@ -235,11 +256,12 @@ endpicture() /* finish and write out pixels */ /* compute final pixel values */ for (p = hres*vres; p--; ) { if (myweight[p] <= FTINY) { - if (lastr >= 0) + if (lastr >= 0) { if (p/hres == lastp/hres) copycolor(mypixel[p], mypixel[lastp]); else copycolor(mypixel[p], mypixel[lastrp]); + } nunrend++; continue; } @@ -258,7 +280,8 @@ endpicture() /* finish and write out pixels */ } -initialize() /* initialize holodeck and buffers */ +static void +initialize(void) /* initialize holodeck and buffers */ { int fd; FILE *fp; @@ -281,7 +304,7 @@ initialize() /* initialize holodeck and buffers */ fd = dup(fileno(fp)); /* dup file descriptor */ fclose(fp); /* done with stdio */ for (n = 0; nextloc > 0L; n++) { /* initialize each section */ - lseek(fd, (off_t)nextloc, 0); + lseek(fd, (off_t)nextloc, SEEK_SET); read(fd, (char *)&nextloc, sizeof(nextloc)); hdinit(fd, NULL); } @@ -289,7 +312,7 @@ initialize() /* initialize holodeck and buffers */ mypixel = (COLOR *)bmalloc(xres*yres*sizeof(COLOR)); myweight = (float *)bmalloc(xres*yres*sizeof(float)); mydepth = (float *)bmalloc(xres*yres*sizeof(float)); - if (mypixel == NULL | myweight == NULL | mydepth == NULL) + if ((mypixel == NULL) | (myweight == NULL) | (mydepth == NULL)) error(SYSTEM, "out of memory in initialize"); }