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.13 by gwlarson, Fri Jan 1 10:41:28 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  
43   #ifndef FEQ
# Line 231 | Line 231 | char  *id;
231          glDisable(GL_CULL_FACE);
232          glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
233          glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
234 +        glPixelStorei(GL_PACK_ALIGNMENT, 1);
235 +        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
236                                          /* figure out sensible view */
237          pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) /
238                          DisplayWidth(ourdisplay, ourscreen);
# Line 248 | Line 250 | char  *id;
250          XMapWindow(ourdisplay, gwind);
251          dev_input();                    /* sets size and view angles */
252          if (!odInit(DisplayWidth(ourdisplay,ourscreen) *
253 <                        DisplayHeight(ourdisplay,ourscreen) / 4))
253 >                        DisplayHeight(ourdisplay,ourscreen) / 3))
254                  error(SYSTEM, "insufficient memory for value storage");
255          odev.name = id;
256          odev.firstuse = 1;              /* can't recycle samples */
# Line 280 | Line 282 | dev_close()                    /* close our display and free resources
282  
283   dev_clear()                     /* clear our representation */
284   {
285 <        wipeclean();
285 >        viewflags |= VWCHANGE;          /* pretend our view has changed */
286 >        wipeclean();                    /* clean off display and samples */
287 >        dev_flush();                    /* redraw geometry & get depth */
288          rayqleft = 0;                   /* hold off update */
289   }
290  
# Line 369 | Line 373 | dev_auxcom(cmd, args)          /* process an auxiliary command
373   char    *cmd, *args;
374   {
375   #ifdef DOBJ
376 <        if (dobj_command(cmd, args) >= 0)
376 >        int     vischange;
377 >
378 >        if ((vischange = dobj_command(cmd, args)) >= 0) {
379 >                if (vischange) {
380 >                        imm_mode = beam_sync(1) > 0;
381 >                        dev_clear();
382 >                }
383                  return;
384 +        }
385   #endif
386          sprintf(errmsg, "%s: unknown command", cmd);
387          error(COMMAND, errmsg);
# Line 502 | Line 513 | xferdepth()                    /* load and clear depth buffer */
513          }
514                                  /* allocate alpha buffer for portals */
515          if (gmPortals)
516 <                pbuf = (GLubyte *)malloc(odev.hres*odev.vres *
506 <                                (4*sizeof(GLubyte)));
516 >                pbuf = (GLubyte *)malloc(odev.hres*odev.vres*sizeof(GLubyte));
517          else
518                  pbuf = NULL;
519   #ifdef STEREO
520 <        setstereobuf(STEREO_BUFFER_RIGHT);
520 >        pushright();
521          glReadPixels(0, 0, odev.hres, odev.vres,
522                          GL_DEPTH_COMPONENT, GL_FLOAT, depthright);
523          if (pbuf != NULL) {
524                  glClear(GL_COLOR_BUFFER_BIT);
525                  gmDrawPortals(0xff, -1, -1, -1);
526                  glReadPixels(0, 0, odev.hres, odev.vres,
527 <                                GL_RGBA, GL_UNSIGNED_BYTE, pbuf);
527 >                                GL_RED, GL_UNSIGNED_BYTE, pbuf);
528          }
529          for (dbp = depthright + odev.hres*odev.vres; dbp-- > depthright; )
530 <                if (pbuf != NULL && pbuf[4*(dbp-depthright)]&0x40)
530 >                if (pbuf != NULL && pbuf[dbp-depthright]&0x40)
531                          *dbp = FHUGE;
532                  else
533                          *dbp = mapdepth(*dbp);
534          glClear(GL_DEPTH_BUFFER_BIT);
525        setstereobuf(STEREO_BUFFER_LEFT);
535          odDepthMap(1, depthright);
536 +        popright();
537   #endif
538                                  /* read back depth buffer */
539          glReadPixels(0, 0, odev.hres, odev.vres,
# Line 532 | Line 542 | xferdepth()                    /* load and clear depth buffer */
542                  glClear(GL_COLOR_BUFFER_BIT);           /* find portals */
543                  gmDrawPortals(0xff, -1, -1, -1);
544                  glReadPixels(0, 0, odev.hres, odev.vres,
545 <                                GL_RGBA, GL_UNSIGNED_BYTE, pbuf);
545 >                                GL_RED, GL_UNSIGNED_BYTE, pbuf);
546 > #ifdef DEBUG
547 >                glXSwapBuffers(ourdisplay, gwind);
548 > #endif
549          }
550          for (dbp = depthbuffer + odev.hres*odev.vres; dbp-- > depthbuffer; )
551 <                if (pbuf != NULL && pbuf[4*(dbp-depthbuffer)]&0x40)
551 >                if (pbuf != NULL && pbuf[dbp-depthbuffer]&0x40)
552                          *dbp = FHUGE;
553                  else
554                          *dbp = mapdepth(*dbp);
# Line 790 | Line 803 | XButtonPressedEvent    *ebut;
803          XNoOp(ourdisplay);              /* makes sure we're not idle */
804  
805          viewflags &= ~VWSTEADY;         /* flag moving view */
806 <        setglpersp(&odev.v);            /* start us off in perspective */
806 >        setglpersp();                   /* start us off in perspective */
807          while (!XCheckMaskEvent(ourdisplay,
808                          ButtonReleaseMask, levptr(XEvent))) {
809                                          /* get cursor position */
# Line 832 | Line 845 | XButtonPressedEvent    *ebut;
845  
846  
847   static
848 < setglpersp(vp)                  /* set perspective view in GL */
836 < register VIEW   *vp;
848 > setglpersp()                    /* set perspective view in GL */
849   {
850          double  d, xmin, xmax, ymin, ymax;
851          GLfloat vec[4];
# Line 845 | Line 857 | register VIEW  *vp;
857                  dev_zmax = 100.;
858          } else {
859                  dev_zmin = 0.5*depthlim[0];
860 <                dev_zmax = 1.75*depthlim[1];
860 >                dev_zmax = 1.25*depthlim[1];
861                  if (dev_zmin > dev_zmax/5.)
862                          dev_zmin = dev_zmax/5.;
863          }
# Line 928 | Line 940 | wipeclean()                    /* prepare for redraw */
940                          (VWCHANGE|VWSTEADY)) {  /* clear samples if new */
941                  odClean();
942                  viewflags &= ~VWCHANGE;         /* change noted */
943 <        }
943 >        } else if (viewflags & VWSTEADY)
944 >                odRedrawAll();
945          setglpersp(&odev.v);            /* reset view & clipping planes */
946   }
947  
# Line 979 | Line 992 | register XKeyPressedEvent  *ekey;
992                  inpresflags |= DFL(DC_RESUME);
993                  return;
994          case CTRL('R'):                 /* redraw screen */
995 <                odRemap(0);
995 >                odRemap(0);                     /* new tone mapping */
996                  glClear(GL_DEPTH_BUFFER_BIT);
997   #ifdef STEREO
998                  setstereobuf(STEREO_BUFFER_RIGHT);
# Line 989 | Line 1002 | register XKeyPressedEvent  *ekey;
1002                  return;
1003          case CTRL('L'):                 /* refresh from server */
1004                  if (inpresflags & DFL(DC_REDRAW))
1005 <                        return;
1005 >                        return;                 /* already called */
1006                  XRaiseWindow(ourdisplay, gwind);
1007 <                XFlush(ourdisplay);
1008 <                sleep(1);
1009 <                wipeclean();                    /* fresh display */
1010 <                odRemap(1);                     /* fresh tone mapping */
998 <                dev_flush();                    /* draw octrees */
1007 >                XFlush(ourdisplay);             /* raise up window */
1008 >                sleep(1);                       /* wait for restacking */
1009 >                dev_clear();                    /* clear buffer and samples */
1010 >                odRemap(1);                     /* start fresh histogram */
1011                  inpresflags |= DFL(DC_REDRAW);  /* resend values from server */
1000                rayqleft = 0;                   /* hold off update */
1012                  return;
1013          case 'K':                       /* kill rtrace process(es) */
1014                  inpresflags |= DFL(DC_KILL);
# Line 1030 | Line 1041 | register XExposeEvent  *eexp;
1041          }
1042          xmin = eexp->x; xmax = eexp->x + eexp->width;
1043          ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y;
1044 +
1045 +        if (xmin <= 0 && xmax >= odev.hres-1 &&
1046 +                        ymin <= 0 && ymax >= odev.vres) {
1047 +                DCHECK(eexp->count, WARNING, "multiple clear in fixwindow");
1048 +                wipeclean();                    /* make sure we're go */
1049 +                return;
1050 +        }
1051                                                  /* clear portion of depth */
1052          glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
1053          glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines