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

Comparing ray/src/hd/rhd_ogl.c (file contents):
Revision 3.9 by gwlarson, Tue Dec 22 12:59:17 1998 UTC vs.
Revision 3.15 by gwlarson, Tue Jan 5 18:16:17 1999 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1998 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1999 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 37 | Line 37 | static char SCCSid[] = "$SunId$ SGI";
37   #include "x11icon.h"
38  
39   #ifndef RAYQLEN
40 < #define RAYQLEN         50000           /* max. rays to queue before flush */
40 > #define RAYQLEN         0               /* max. rays to queue before flush */
41   #endif
42 + #ifndef MINWIDTH
43 + #define MINWIDTH        480             /* minimum graphics window width */
44 + #define MINHEIGHT       400             /* minimum graphics window height */
45 + #endif
46 + #ifndef VIEWDIST
47 + #define VIEWDIST        356             /* assumed viewing distance (mm) */
48 + #endif
49 + #ifndef BORWIDTH
50 + #define BORWIDTH        5               /* border width */
51 + #endif
52  
53   #ifndef FEQ
54   #define FEQ(a,b)        ((a)-(b) <= FTINY && (a)-(b) >= -FTINY)
# Line 60 | Line 70 | static char SCCSid[] = "$SunId$ SGI";
70   #define MOVDEG          (-5)            /* degrees to orbit CW/down /frame */
71   #define MOVORB(s)       ((s)&ShiftMask ? 1 : (s)&ControlMask ? -1 : 0)
72  
63 #define MINWIDTH        480             /* minimum graphics window width */
64 #define MINHEIGHT       400             /* minimum graphics window height */
65
66 #define VIEWDIST        356             /* assumed viewing distance (mm) */
67
68 #define BORWIDTH        5               /* border width */
69
73   #define setstereobuf(bid)       (glXWaitGL(), \
74                                  XSGISetStereoBuffer(ourdisplay, gwind, bid), \
75                                  glXWaitX())
# Line 231 | Line 234 | char  *id;
234          glDisable(GL_CULL_FACE);
235          glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
236          glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
237 +        glPixelStorei(GL_PACK_ALIGNMENT, 1);
238 +        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
239                                          /* figure out sensible view */
240          pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) /
241                          DisplayWidth(ourdisplay, ourscreen);
# Line 248 | Line 253 | char  *id;
253          XMapWindow(ourdisplay, gwind);
254          dev_input();                    /* sets size and view angles */
255          if (!odInit(DisplayWidth(ourdisplay,ourscreen) *
256 <                        DisplayHeight(ourdisplay,ourscreen) / 4))
256 >                        DisplayHeight(ourdisplay,ourscreen) / 3))
257                  error(SYSTEM, "insufficient memory for value storage");
258          odev.name = id;
259          odev.firstuse = 1;              /* can't recycle samples */
# Line 280 | Line 285 | dev_close()                    /* close our display and free resources
285  
286   dev_clear()                     /* clear our representation */
287   {
288 <        wipeclean();
288 >        viewflags |= VWCHANGE;          /* pretend our view has changed */
289 >        wipeclean();                    /* clean off display and samples */
290 >        dev_flush();                    /* redraw geometry & get depth */
291          rayqleft = 0;                   /* hold off update */
292   }
293  
# Line 327 | Line 334 | register VIEW  *nv;
334                          dev_input();    /* get resize event */
335                  }
336                  copystruct(&odev.v, nv);        /* setview() already called */
330 #ifdef STEREO
331                copystruct(&vwright, nv);
332                d = eyesepdist / sqrt(nv->hn2);
333                VSUM(vwright.vp, nv->vp, nv->hvec, d);
334                /* setview(&vwright);   -- Unnecessary */
335 #endif
337                  viewflags |= VWCHANGE;
338          }
339 + #ifdef STEREO
340 +        copystruct(&vwright, nv);
341 +        d = eyesepdist / sqrt(nv->hn2);
342 +        VSUM(vwright.vp, nv->vp, nv->hvec, d);
343 +        /* setview(&vwright);   -- Unnecessary */
344 + #endif
345          wipeclean();
346          return(1);
347   }
# Line 369 | Line 376 | dev_auxcom(cmd, args)          /* process an auxiliary command
376   char    *cmd, *args;
377   {
378   #ifdef DOBJ
379 <        if (dobj_command(cmd, args) >= 0)
379 >        int     vischange;
380 >
381 >        if ((vischange = dobj_command(cmd, args)) >= 0) {
382 >                if (vischange) {
383 >                        imm_mode = beam_sync(1) > 0;
384 >                        dev_clear();
385 >                }
386                  return;
387 +        }
388   #endif
389          sprintf(errmsg, "%s: unknown command", cmd);
390          error(COMMAND, errmsg);
# Line 502 | Line 516 | xferdepth()                    /* load and clear depth buffer */
516          }
517                                  /* allocate alpha buffer for portals */
518          if (gmPortals)
519 <                pbuf = (GLubyte *)malloc(odev.hres*odev.vres *
506 <                                (4*sizeof(GLubyte)));
519 >                pbuf = (GLubyte *)malloc(odev.hres*odev.vres*sizeof(GLubyte));
520          else
521                  pbuf = NULL;
522   #ifdef STEREO
523 <        setstereobuf(STEREO_BUFFER_RIGHT);
523 >        pushright();
524          glReadPixels(0, 0, odev.hres, odev.vres,
525                          GL_DEPTH_COMPONENT, GL_FLOAT, depthright);
526          if (pbuf != NULL) {
527                  glClear(GL_COLOR_BUFFER_BIT);
528                  gmDrawPortals(0xff, -1, -1, -1);
529                  glReadPixels(0, 0, odev.hres, odev.vres,
530 <                                GL_RGBA, GL_UNSIGNED_BYTE, pbuf);
530 >                                GL_RED, GL_UNSIGNED_BYTE, pbuf);
531          }
532          for (dbp = depthright + odev.hres*odev.vres; dbp-- > depthright; )
533 <                if (pbuf != NULL && pbuf[4*(dbp-depthright)]&0x40)
533 >                if (pbuf != NULL && pbuf[dbp-depthright]&0x40)
534                          *dbp = FHUGE;
535                  else
536                          *dbp = mapdepth(*dbp);
537          glClear(GL_DEPTH_BUFFER_BIT);
525        setstereobuf(STEREO_BUFFER_LEFT);
538          odDepthMap(1, depthright);
539 +        popright();
540   #endif
541                                  /* read back depth buffer */
542          glReadPixels(0, 0, odev.hres, odev.vres,
# Line 532 | Line 545 | xferdepth()                    /* load and clear depth buffer */
545                  glClear(GL_COLOR_BUFFER_BIT);           /* find portals */
546                  gmDrawPortals(0xff, -1, -1, -1);
547                  glReadPixels(0, 0, odev.hres, odev.vres,
548 <                                GL_RGBA, GL_UNSIGNED_BYTE, pbuf);
548 >                                GL_RED, GL_UNSIGNED_BYTE, pbuf);
549 > #ifdef DEBUG
550 >                glXSwapBuffers(ourdisplay, gwind);
551 > #endif
552          }
553          for (dbp = depthbuffer + odev.hres*odev.vres; dbp-- > depthbuffer; )
554 <                if (pbuf != NULL && pbuf[4*(dbp-depthbuffer)]&0x40)
554 >                if (pbuf != NULL && pbuf[dbp-depthbuffer]&0x40)
555                          *dbp = FHUGE;
556                  else
557                          *dbp = mapdepth(*dbp);
# Line 790 | Line 806 | XButtonPressedEvent    *ebut;
806          XNoOp(ourdisplay);              /* makes sure we're not idle */
807  
808          viewflags &= ~VWSTEADY;         /* flag moving view */
809 <        setglpersp(&odev.v);            /* start us off in perspective */
809 >        setglpersp();                   /* start us off in perspective */
810          while (!XCheckMaskEvent(ourdisplay,
811                          ButtonReleaseMask, levptr(XEvent))) {
812                                          /* get cursor position */
# Line 832 | Line 848 | XButtonPressedEvent    *ebut;
848  
849  
850   static
851 < setglpersp(vp)                  /* set perspective view in GL */
836 < register VIEW   *vp;
851 > setglpersp()                    /* set perspective view in GL */
852   {
853          double  d, xmin, xmax, ymin, ymax;
854          GLfloat vec[4];
# Line 845 | Line 860 | register VIEW  *vp;
860                  dev_zmax = 100.;
861          } else {
862                  dev_zmin = 0.5*depthlim[0];
863 <                dev_zmax = 1.75*depthlim[1];
863 >                dev_zmax = 1.25*depthlim[1];
864                  if (dev_zmin > dev_zmax/5.)
865                          dev_zmin = dev_zmax/5.;
866          }
# Line 928 | Line 943 | wipeclean()                    /* prepare for redraw */
943                          (VWCHANGE|VWSTEADY)) {  /* clear samples if new */
944                  odClean();
945                  viewflags &= ~VWCHANGE;         /* change noted */
946 <        }
946 >        } else if (viewflags & VWSTEADY)
947 >                odRedrawAll();
948          setglpersp(&odev.v);            /* reset view & clipping planes */
949   }
950  
# Line 979 | Line 995 | register XKeyPressedEvent  *ekey;
995                  inpresflags |= DFL(DC_RESUME);
996                  return;
997          case CTRL('R'):                 /* redraw screen */
998 <                odRemap(0);
998 >                odRemap(0);                     /* new tone mapping */
999                  glClear(GL_DEPTH_BUFFER_BIT);
1000   #ifdef STEREO
1001                  setstereobuf(STEREO_BUFFER_RIGHT);
# Line 989 | Line 1005 | register XKeyPressedEvent  *ekey;
1005                  return;
1006          case CTRL('L'):                 /* refresh from server */
1007                  if (inpresflags & DFL(DC_REDRAW))
1008 <                        return;
1008 >                        return;                 /* already called */
1009                  XRaiseWindow(ourdisplay, gwind);
1010 <                XFlush(ourdisplay);
1011 <                sleep(1);
1012 <                wipeclean();                    /* fresh display */
1013 <                odRemap(1);                     /* fresh tone mapping */
998 <                dev_flush();                    /* draw octrees */
1010 >                XFlush(ourdisplay);             /* raise up window */
1011 >                sleep(1);                       /* wait for restacking */
1012 >                dev_clear();                    /* clear buffer and samples */
1013 >                odRemap(1);                     /* start fresh histogram */
1014                  inpresflags |= DFL(DC_REDRAW);  /* resend values from server */
1000                rayqleft = 0;                   /* hold off update */
1015                  return;
1016          case 'K':                       /* kill rtrace process(es) */
1017                  inpresflags |= DFL(DC_KILL);
# Line 1030 | Line 1044 | register XExposeEvent  *eexp;
1044          }
1045          xmin = eexp->x; xmax = eexp->x + eexp->width;
1046          ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y;
1047 +
1048 +        if (xmin <= 0 && xmax >= odev.hres-1 &&
1049 +                        ymin <= 0 && ymax >= odev.vres) {
1050 +                DCHECK(eexp->count, WARNING, "multiple clear in fixwindow");
1051 +                wipeclean();                    /* make sure we're go */
1052 +                return;
1053 +        }
1054                                                  /* clear portion of depth */
1055          glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
1056          glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines