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.3 by gwlarson, Tue Jun 9 15:16:55 1998 UTC vs.
Revision 3.4 by gwlarson, Wed Jun 10 17:52:18 1998 UTC

# Line 13 | Line 13 | static char SCCSid[] = "$SunId$ SGI";
13   #include "paths.h"
14   #include <sys/types.h>
15   #include <GL/glx.h>
16 + #ifndef NOSTEREO
17 + #include <X11/extensions/SGIStereo.h>
18 + #endif
19   #include <ctype.h>
20   #include "glradicon.h"
21  
# Line 65 | Line 68 | struct {
68  
69   int     currentview = 0;                /* current view number */
70   VIEW    thisview = STDVIEW;             /* displayed view */
71 + double  eyedist = 1;                    /* interocular distance */
72   VIEW    lastview;                       /* last recorded view */
73  
74   char    *progname;                      /* global argv[0] */
# Line 75 | Line 79 | char   *octree;                        /* octree name (NULL if unnec.) */
79  
80   int     rtpd[3];                        /* rtrace process descriptors */
81  
82 + int     silent = 0;                     /* run rad silently? */
83   int     backvis = 1;                    /* back faces visible? */
84 + int     stereo = 0;                     /* do stereo? */
85  
86 + #ifdef NOSTEREO
87 + #define setstereobuf(bid)       0
88 + #else
89 + #define setstereobuf(bid)       (glXWaitGL(), \
90 +                                XSGISetStereoBuffer(ourdisplay, gwind, bid), \
91 +                                glXWaitX())
92 + #endif
93 +
94   int     displist;                       /* our scene display list */
95  
96   int     in_dev_view = 0;                /* currently in dev_view() */
97  
98 < extern char     *fgets(), *fgetline(), *atos(), *scan4var();
98 > #ifdef BSD
99 > #define strchr          index
100 > #endif
101 >
102 > extern char     *strchr(), *fgets(), *fgetline(), *atos(), *scan4var();
103   extern int      nowarn;                 /* turn warnings off? */
104   extern time_t   time();
105  
# Line 103 | Line 121 | char   *argv[];
121                  case 'w':
122                          nowarn = !nowarn;
123                          break;
124 +                case 's':
125 +                        silent = !silent;
126 +                        break;
127 +                case 'S':
128 +                        stereo = !stereo;
129 +                        break;
130                  case 'c':
131                          vwintvl = atoi(argv[++i]);
132                          break;
# Line 114 | Line 138 | char   *argv[];
138                  }
139          if (i >= argc)
140                  goto userr;
141 + #ifdef NOSTEREO
142 +        if (stereo)
143 +                error(INTERNAL, "stereo not supported in this version");
144 + #endif
145                                          /* run rad and get views */
146          runrad(argc-i, argv+i);
147                                          /* check view */
# Line 196 | Line 224 | char   **av;
224                                          /* set rad commmand */
225          strcpy(radcomm, "rad -w -v 0        "); /* look out below! */
226          cp = radcomm + 19;
227 +        if (silent) {
228 +                strcpy(cp, "-s ");
229 +                cp += 3;
230 +        }
231          while (ac--) {
232                  strcpy(cp, *av++);
233                  while (*cp) cp++;
# Line 218 | Line 250 | char   **av;
250                          expval = pow(2., expval);
251                  expval *= 0.5;          /* compensate for local shading */
252          }
253 +                                                /* look for eye separation */
254 +        if ((cp = scan4var(buf, sizeof(buf), "EYESEP", fp)) != NULL)
255 +                eyedist = atof(cp);
256                                                  /* look for materials */
257          while ((cp = scan4var(buf, sizeof(buf), "materials", fp)) != NULL) {
258                  nscenef += wordstring(scene+nscenef, cp);
# Line 258 | Line 293 | char   **av;
293                                                  /* open options file */
294          if ((fp = fopen(optfile, "r")) == NULL)
295                  error(SYSTEM, "cannot open options file");
296 <                                                /* get ambient value */
296 >                                                /* get relevant options */
297          while (fgets(buf, sizeof(buf), fp) != NULL)
298 <                if (!strncmp(buf, "-av ", 4)) {
298 >                if (!strncmp(buf, "-av ", 4))
299                          setcolor(ambval, atof(buf+4),
300                                          atof(sskip2(buf+4,1)),
301                                          atof(sskip2(buf+4,2)));
302 <                        break;
303 <                }
302 >                else if (backvis && !strncmp(buf, "-bv", 3) &&
303 >                                (!buf[3] || strchr(" 0-FfNn", buf[3]) != NULL))
304 >                        backvis = 0;
305          fclose(fp);
306          unlink(optfile);                        /* delete options file */
307   }
# Line 364 | Line 400 | char  *id;
400          if (gwind == 0)
401                  error(SYSTEM, "cannot create window\n");
402          XStoreName(ourdisplay, gwind, id);
403 + #ifndef NOSTEREO
404 +        if (stereo)                     /* check if stereo working */
405 +                switch (XSGIQueryStereoMode(ourdisplay, gwind)) {
406 +                case STEREO_TOP:
407 +                case STEREO_BOTTOM:
408 +                        break;
409 +                case STEREO_OFF:
410 +                        error(USER,
411 +                "wrong video mode: run \"/usr/gfx/setmon -n STR_TOP\" first");
412 +                case X_STEREO_UNSUPPORTED:
413 +                        error(USER, "stereo not supported on this screen");
414 +                default:
415 +                        error(INTERNAL, "unknown stereo mode");
416 +                }
417 + #endif
418                                          /* set window manager hints */
419          ourxwmhints.flags = InputHint|IconPixmapHint;
420          ourxwmhints.input = True;
# Line 371 | Line 422 | char  *id;
422                  gwind, glradicon_bits, glradicon_width, glradicon_height);
423          XSetWMHints(ourdisplay, gwind, &ourxwmhints);
424          oursizhints.min_width = MINWIDTH;
425 <        oursizhints.min_height = MINHEIGHT;
425 >        oursizhints.min_height = stereo ? MINHEIGHT/2 : MINHEIGHT;
426          oursizhints.flags = PMinSize;
427          XSetNormalHints(ourdisplay, gwind, &oursizhints);
428                                          /* set GLX context */
# Line 395 | Line 446 | char  *id;
446                          DisplayWidth(ourdisplay, ourscreen);
447          pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) /
448                          DisplayHeight(ourdisplay, ourscreen);
449 +        if (stereo) {                   /* set stereo mode */
450 +                setstereobuf(STEREO_BUFFER_LEFT);
451 +                pheight *= 2.;
452 +        }
453                                          /* map the window */
454          XMapWindow(ourdisplay, gwind);
455          do
# Line 507 | Line 562 | int    nsecs;
562  
563   render()                        /* render our display list and swap buffers */
564   {
565 +        double  d;
566 +
567          if (!mapped)
568                  return;
569          glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
570          glCallList(displist);
571 +        if (stereo) {                           /* do right eye for stereo */
572 +                setstereobuf(STEREO_BUFFER_RIGHT);
573 +                glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
574 +                glMatrixMode(GL_MODELVIEW);
575 +                glPushMatrix();
576 +                d = -eyedist / sqrt(thisview.hn2);
577 +                glTranslated(d*thisview.hvec[0], d*thisview.hvec[1],
578 +                                d*thisview.hvec[2]);
579 +                glCallList(displist);
580 +                glMatrixMode(GL_MODELVIEW);
581 +                glPopMatrix();
582 +                setstereobuf(STEREO_BUFFER_LEFT);
583 +        }
584          glXSwapBuffers(ourdisplay, gwind);      /* calls glFlush() */
585          rgl_checkerr("rendering display list");
586   }
# Line 747 | Line 817 | int    vwnum;
817                  vwnum = 0;
818          if (vwnum == currentview)
819                  return;
820 <        /* copylastv("change view"); */
820 >        copylastv("standard view");
821          dev_view(vwl[currentview=vwnum].v);
822   }
823  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines