--- ray/src/util/glrad.c 2003/02/22 02:07:30 3.13 +++ ray/src/util/glrad.c 2003/07/21 22:30:19 3.17 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: glrad.c,v 3.13 2003/02/22 02:07:30 greg Exp $"; +static const char RCSid[] = "$Id: glrad.c,v 3.17 2003/07/21 22:30:19 schorsch Exp $"; #endif /* * Program to display Radiance scene using OpenGL. @@ -11,11 +11,14 @@ static const char RCSid[] = "$Id: glrad.c,v 3.13 2003/ #include #endif #include +#include #include + #include "radogl.h" #include "view.h" #include "paths.h" #include "glradicon.h" +#include "rtprocess.h" #ifndef MAXVIEW #define MAXVIEW 63 /* maximum number of standard views */ @@ -72,7 +75,7 @@ char *scene[MAXSCENE+1]; /* material and scene file l int nscenef = 0; /* number of scene files */ char *octree; /* octree name (NULL if unnec.) */ -int rtpd[3]; /* rtrace process descriptors */ +SUBPROC rtpd; /* rtrace process descriptors */ int silent = 0; /* run rad silently? */ int backvis = 1; /* back faces visible? */ @@ -90,13 +93,8 @@ int displist; /* our scene display list */ int no_render = 0; /* don't rerender */ -#ifdef BSD -#define strchr index -#endif - -extern char *strchr(), *fgets(), *fgetline(), *atos(), *scan4var(); +extern char *fgetline(), *atos(), *scan4var(); extern int nowarn; /* turn warnings off? */ -extern time_t time(); main(argc, argv) @@ -140,7 +138,7 @@ char *argv[]; /* run rad and get views */ runrad(argc-i, argv+i); /* check view */ - if (viewsel != NULL) + if (viewsel != NULL) { if (viewsel[0] == '-') { char *ve = viewsel; if (!sscanview(&thisview, viewsel) || @@ -155,6 +153,7 @@ char *argv[]; progname, viewsel); quit(1); } + } /* open GL */ dev_open(radfile = argv[i]); /* load octree or scene files */ @@ -184,10 +183,11 @@ int code; { if (ourdisplay != NULL) dev_close(); - if (rtpd[2] > 0) { - if (close_process(rtpd) > 0) + /* if (rtpd.pid > 0) { */ + if (rtpd.running) { + if (close_process(&rtpd) > 0) wputs("bad exit status from rtrace\n"); - rtpd[2] = 0; + /* rtpd.pid = 0; */ } exit(code); } @@ -203,7 +203,7 @@ char *octname; if (nowarn) av[ac++] = "-w-"; av[ac++] = octname; av[ac] = NULL; - if (open_process(rtpd, av) <= 0) + if (open_process(&rtpd, av) <= 0) error(SYSTEM, "cannot start rtrace process"); } @@ -275,7 +275,7 @@ char **av; do if (isview(buf)) { vwl[nvv].v = (VIEW *)bmalloc(sizeof(VIEW)); - copystruct(vwl[nvv].v, &stdview); + *(vwl[nvv].v) = stdview; sscanview(vwl[nvv].v, buf); if ((cp = setview(vwl[nvv++].v)) != NULL) { fprintf(stderr, "%s: bad view %d - %s\n", @@ -506,7 +506,7 @@ register VIEW *nv; no_render--; } } - copystruct(&thisview, nv); + thisview = *nv; setglpersp(&thisview); render(); return(1); @@ -585,9 +585,8 @@ int dx, dy, mov, orb; VIEW nv; FVECT odir, v1, wp; double d; - register int li; /* start with old view */ - copystruct(&nv, &thisview); + nv = thisview; /* change view direction */ if ((d = viewray(v1, odir, &thisview, (dx+.5)/hres, (dy+.5)/vres)) < -FTINY) @@ -680,7 +679,8 @@ double md; { float fbuf[6]; /* check to see if rtrace is running */ - if (rtpd[2] <= 0) + /* if (rtpd.pid <= 0) */ + if (!rtpd.running) return(0); /* assign origin */ fbuf[0] = org[0]; fbuf[1] = org[1]; fbuf[2] = org[2]; @@ -688,7 +688,7 @@ double md; if (md <= FTINY) md = FHUGE; fbuf[3] = dir[0]*md; fbuf[4] = dir[1]*md; fbuf[5] = dir[2]*md; /* trace that ray */ - if (process(rtpd, (char *)fbuf, (char *)fbuf, + if (process(&rtpd, (char *)fbuf, (char *)fbuf, 4*sizeof(float), 6*sizeof(float)) != 4*sizeof(float)) error(INTERNAL, "error getting data back from rtrace process"); if (fbuf[3] >= .99*FHUGE) @@ -750,9 +750,9 @@ register XKeyPressedEvent *ekey; case 'l': /* retrieve last (premouse) view */ if (lastview.type) { VIEW vtmp; - copystruct(&vtmp, &thisview); + vtmp = thisview; dev_view(&lastview); - copystruct(&lastview, &vtmp); + lastview = vtmp; } else XBell(ourdisplay, 0); break; @@ -831,7 +831,7 @@ VIEW *vp; { FILE *fp; /* check if already in there */ - if (!bcmp(&thisview, vwl[currentview].v, sizeof(VIEW))) { + if (!memcmp(&thisview, vwl[currentview].v, sizeof(VIEW))) { error(COMMAND, "view already in standard list"); return; } @@ -852,7 +852,7 @@ VIEW *vp; if (currentview >= MAXVIEW) error(INTERNAL, "too many views in appendview"); vwl[currentview].v = (VIEW *)bmalloc(sizeof(VIEW)); - copystruct(vwl[currentview].v, &thisview); + *(vwl[currentview].v) = thisview; if (nm != NULL) vwl[currentview].nam = savqstr(nm); } @@ -866,7 +866,7 @@ char *cause; if (cause == lastvc) return; /* only record one view per cause */ lastvc = cause; - copystruct(&lastview, &thisview); + lastview = thisview; }