ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/glrad.c
(Generate patch)

Comparing ray/src/util/glrad.c (file contents):
Revision 3.6 by gwlarson, Fri Jun 19 11:29:50 1998 UTC vs.
Revision 3.15 by schorsch, Thu Jun 26 00:58:11 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Program to display Radiance scene using OpenGL.
6   */
7  
11 #include "radogl.h"
12 #include "view.h"
13 #include "paths.h"
8   #include <sys/types.h>
9   #include <GL/glx.h>
10   #ifndef NOSTEREO
11   #include <X11/extensions/SGIStereo.h>
12   #endif
13   #include <ctype.h>
14 + #include <time.h>
15 +
16 + #include "radogl.h"
17 + #include "view.h"
18 + #include "paths.h"
19   #include "glradicon.h"
20 + #include "rtprocess.h"
21  
22   #ifndef MAXVIEW
23   #define MAXVIEW         63              /* maximum number of standard views */
# Line 74 | Line 74 | char   *scene[MAXSCENE+1];             /* material and scene file l
74   int     nscenef = 0;                    /* number of scene files */
75   char    *octree;                        /* octree name (NULL if unnec.) */
76  
77 < int     rtpd[3];                        /* rtrace process descriptors */
77 > SUBPROC rtpd;                   /* rtrace process descriptors */
78  
79   int     silent = 0;                     /* run rad silently? */
80   int     backvis = 1;                    /* back faces visible? */
# Line 92 | Line 92 | int    displist;                       /* our scene display list */
92  
93   int     no_render = 0;                  /* don't rerender */
94  
95 < #ifdef BSD
96 < #define strchr          index
97 < #endif
98 <
99 < extern char     *strchr(), *fgets(), *fgetline(), *atos(), *scan4var();
95 > extern char     *fgetline(), *atos(), *scan4var();
96   extern int      nowarn;                 /* turn warnings off? */
101 extern time_t   time();
97  
98  
99   main(argc, argv)
# Line 161 | Line 156 | char   *argv[];
156          dev_open(radfile = argv[i]);
157                                          /* load octree or scene files */
158          if (octree != NULL) {
159 <                displist = rgl_octlist(octree, NULL, NULL);
159 >                displist = rgl_octlist(octree, NULL, NULL, NULL);
160                  startrtrace(octree);
161          } else
162 <                displist = rgl_filelist(nscenef, scene);
162 >                displist = rgl_filelist(nscenef, scene, NULL);
163                                          /* set initial view */
164          dev_view(currentview < 0 ? &thisview : vwl[currentview].v);
165                                          /* input/render loop */
# Line 173 | Line 168 | char   *argv[];
168                                          /* all done */
169          quit(0);
170   userr:
171 <        fprintf(stderr, "Usage: %s [-w][-b][-v view] rfile [VAR=value]..\n",
171 >        fprintf(stderr,
172 >                "Usage: %s [-w][-s][-b][-S][-v view] rfile [VAR=value]..\n",
173                          argv[0]);
174          quit(1);
175   }
176  
177  
178 + void
179   quit(code)                              /* exit gracefully */
180   int     code;
181   {
182          if (ourdisplay != NULL)
183                  dev_close();
184 <        if (rtpd[2] > 0) {
185 <                if (close_process(rtpd) > 0)
184 >        /* if (rtpd.pid > 0) { */
185 >        if (rtpd.running) {
186 >                if (close_process(&rtpd) > 0)
187                          wputs("bad exit status from rtrace\n");
188 <                rtpd[2] = 0;
188 >                /* rtpd.pid = 0; */
189          }
190          exit(code);
191   }
# Line 203 | Line 201 | char   *octname;
201          if (nowarn) av[ac++] = "-w-";
202          av[ac++] = octname;
203          av[ac] = NULL;
204 <        if (open_process(rtpd, av) <= 0)
204 >        if (open_process(&rtpd, av) <= 0)
205                  error(SYSTEM, "cannot start rtrace process");
206   }
207  
# Line 297 | Line 295 | char   **av;
295                                          atof(sskip2(buf+4,1)),
296                                          atof(sskip2(buf+4,2)));
297                  else if (backvis && !strncmp(buf, "-bv", 3) &&
298 <                                (!buf[3] || strchr(" 0-FfNn", buf[3]) != NULL))
298 >                                (!buf[3] || strchr("0-FfNn \n",buf[3])!=NULL))
299                          backvis = 0;
300          fclose(fp);
301          unlink(optfile);                        /* delete options file */
# Line 423 | Line 421 | char  *id;
421          glDepthFunc(GL_LESS);
422          glShadeModel(GL_SMOOTH);
423          glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
424 <        glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
424 >        glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
425          glEnable(GL_LIGHTING);
426 +        glFrontFace(GL_CCW);
427 +        glCullFace(GL_BACK);
428          if (backvis)
429                  glDisable(GL_CULL_FACE);
430 <        else {
431 <                glFrontFace(GL_CCW);
432 <                glCullFace(GL_BACK);
430 >        else
431                  glEnable(GL_CULL_FACE);
434        }
432          glDrawBuffer(GL_BACK);
433                                          /* figure out sensible view */
434          pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) /
# Line 626 | Line 623 | int    dx, dy, mov, orb;
623   }
624  
625  
626 + static
627 + waitabit()                              /* pause a moment */
628 + {
629 +        struct timespec ts;
630 +        ts.tv_sec = 0;
631 +        ts.tv_nsec = 5000000;
632 +        nanosleep(&ts, NULL);
633 + }
634 +
635 +
636   getmove(ebut)                           /* get view change */
637   XButtonPressedEvent     *ebut;
638   {
# Line 642 | Line 649 | XButtonPressedEvent    *ebut;
649  
650          while (!XCheckMaskEvent(ourdisplay,
651                          ButtonReleaseMask, levptr(XEvent))) {
652 +                                        /* pause so as not to move too fast */
653 +                waitabit();
654  
655                  if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
656                                  &rootx, &rooty, &wx, &wy, &statemask))
# Line 669 | Line 678 | double md;
678   {
679          float   fbuf[6];
680                                  /* check to see if rtrace is running */
681 <        if (rtpd[2] <= 0)
681 >        /* if (rtpd.pid <= 0) */
682 >        if (!rtpd.running)
683                  return(0);
684                                  /* assign origin */
685          fbuf[0] = org[0]; fbuf[1] = org[1]; fbuf[2] = org[2];
# Line 677 | Line 687 | double md;
687          if (md <= FTINY) md = FHUGE;
688          fbuf[3] = dir[0]*md; fbuf[4] = dir[1]*md; fbuf[5] = dir[2]*md;
689                                  /* trace that ray */
690 <        if (process(rtpd, fbuf, fbuf, 4*sizeof(float), 6*sizeof(float)) !=
691 <                        4*sizeof(float))
690 >        if (process(&rtpd, (char *)fbuf, (char *)fbuf,
691 >                        4*sizeof(float), 6*sizeof(float)) != 4*sizeof(float))
692                  error(INTERNAL, "error getting data back from rtrace process");
693          if (fbuf[3] >= .99*FHUGE)
694                  return(0);      /* missed local objects */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines