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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines