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.7 by gwlarson, Tue Dec 22 09:40:32 1998 UTC vs.
Revision 3.10 by gwlarson, Wed Dec 23 17:43:42 1998 UTC

# Line 40 | Line 40 | static char SCCSid[] = "$SunId$ SGI";
40   #define RAYQLEN         50000           /* max. rays to queue before flush */
41   #endif
42  
43 #ifndef PORTALP
44 #define PORTRED         2               /* portal red color */
45 #define PORTGRN         -1              /* portal green left alone */
46 #define PORTBLU         128             /* portal blue color */
47 #define PORTALP         -1              /* don't use alpha channel */
48 #endif
49 #define isportal(c)     ((PORTRED<0 || (c)[0]==PORTRED) && \
50                                (PORTGRN<0 || (c)[1]==PORTGRN) && \
51                                (PORTBLU<0 || (c)[2]==PORTBLU) && \
52                                (PORTALP<0 || (c)[3]==PORTALP))
53
43   #ifndef FEQ
44   #define FEQ(a,b)        ((a)-(b) <= FTINY && (a)-(b) >= -FTINY)
45   #endif
# Line 143 | Line 132 | char  *id;
132   {
133          extern char     *getenv();
134          static RGBPRIMS myprims = STDPRIMS;
146 #if (PORTALP<0)
135          static int      atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
136                                  GLX_RED_SIZE,8, GLX_GREEN_SIZE,8,
137                                  GLX_BLUE_SIZE,8, GLX_DEPTH_SIZE,15, None};
138          static int      atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
139                                  GLX_RED_SIZE,4, GLX_GREEN_SIZE,4,
140                                  GLX_BLUE_SIZE,4, GLX_DEPTH_SIZE,15, None};
153 #else
154        static int      atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
155                                GLX_RED_SIZE,8, GLX_GREEN_SIZE,8,
156                                GLX_BLUE_SIZE,8, GLX_ALPHA_SIZE,2,
157                                GLX_DEPTH_SIZE,15, None};
158        static int      atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
159                                GLX_RED_SIZE,4, GLX_GREEN_SIZE,4,
160                                GLX_BLUE_SIZE,4, GLX_ALPHA_SIZE,2,
161                                GLX_DEPTH_SIZE,15, None};
162 #endif
141          char    *ev;
142          double  gamval = GAMMA;
143          RGBPRIMP        dpri = stdprims;
# Line 248 | Line 226 | char  *id;
226          glXMakeCurrent(ourdisplay, gwind, gctx);
227          glEnable(GL_DEPTH_TEST);
228          glDepthFunc(GL_LEQUAL);
229 <        glEnable(GL_DITHER);
229 >        glClearColor(0, 0, 0, 0);
230          glFrontFace(GL_CCW);
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 302 | 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          rayqleft = 0;                   /* hold off update */
288   }
289  
# Line 459 | Line 440 | dev_flush()                    /* flush output as appropriate */
440   #ifdef DOBJ
441                  ndrawn += dobj_render();
442   #endif
462                if (ndrawn && gmPortals)
463                        gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP);
443                  checkglerr("rendering right eye");
444                  popright();                     /* draw left eye */
445   #endif
# Line 468 | Line 447 | dev_flush()                    /* flush output as appropriate */
447   #ifdef DOBJ
448                  ndrawn += dobj_render();
449   #endif
471                if (ndrawn && gmPortals)
472                        gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP);
450                  glXSwapBuffers(ourdisplay, gwind);
451                  checkglerr("rendering base view");
452          }
# Line 515 | Line 492 | static
492   xferdepth()                     /* load and clear depth buffer */
493   {
494          register GLfloat        *dbp;
495 <        register GLubyte        *cbuf;
495 >        register GLubyte        *pbuf;
496  
497          if (depthbuffer == NULL) {      /* allocate private depth buffer */
498   #ifdef STEREO
# Line 528 | Line 505 | xferdepth()                    /* load and clear depth buffer */
505          }
506                                  /* allocate alpha buffer for portals */
507          if (gmPortals)
508 <                cbuf = (GLubyte *)malloc(odev.hres*odev.vres *
532 <                                                        (4*sizeof(GLubyte)));
508 >                pbuf = (GLubyte *)malloc(odev.hres*odev.vres*sizeof(GLubyte));
509          else
510 <                cbuf = NULL;
510 >                pbuf = NULL;
511   #ifdef STEREO
512          setstereobuf(STEREO_BUFFER_RIGHT);
513          glReadPixels(0, 0, odev.hres, odev.vres,
514                          GL_DEPTH_COMPONENT, GL_FLOAT, depthright);
515 <        if (cbuf != NULL)
515 >        if (pbuf != NULL) {
516 >                glClear(GL_COLOR_BUFFER_BIT);
517 >                gmDrawPortals(0xff, -1, -1, -1);
518                  glReadPixels(0, 0, odev.hres, odev.vres,
519 <                                GL_RGBA, GL_UNSIGNED_BYTE, cbuf);
519 >                                GL_RED, GL_UNSIGNED_BYTE, pbuf);
520 >        }
521          for (dbp = depthright + odev.hres*odev.vres; dbp-- > depthright; )
522 <                if (cbuf != NULL && isportal(cbuf+4*(dbp-depthright)))
522 >                if (pbuf != NULL && pbuf[dbp-depthright]&0x40)
523                          *dbp = FHUGE;
524                  else
525                          *dbp = mapdepth(*dbp);
# Line 551 | Line 530 | xferdepth()                    /* load and clear depth buffer */
530                                  /* read back depth buffer */
531          glReadPixels(0, 0, odev.hres, odev.vres,
532                          GL_DEPTH_COMPONENT, GL_FLOAT, depthbuffer);
533 <        if (cbuf != NULL)
533 >        if (pbuf != NULL) {
534 >                glClear(GL_COLOR_BUFFER_BIT);           /* find portals */
535 >                gmDrawPortals(0xff, -1, -1, -1);
536                  glReadPixels(0, 0, odev.hres, odev.vres,
537 <                                GL_RGBA, GL_UNSIGNED_BYTE, cbuf);
537 >                                GL_RED, GL_UNSIGNED_BYTE, pbuf);
538 > #ifdef DEBUG
539 >                glXSwapBuffers(ourdisplay, gwind);
540 > #endif
541 >        }
542          for (dbp = depthbuffer + odev.hres*odev.vres; dbp-- > depthbuffer; )
543 <                if (cbuf != NULL && isportal(cbuf+4*(dbp-depthbuffer)))
543 >                if (pbuf != NULL && pbuf[dbp-depthbuffer]&0x40)
544                          *dbp = FHUGE;
545                  else
546                          *dbp = mapdepth(*dbp);
547          glClear(GL_DEPTH_BUFFER_BIT);           /* clear system depth buffer */
563        if (cbuf != NULL)
564                free((char *)cbuf);             /* free our color buffer */
548          odDepthMap(0, depthbuffer);             /* transfer depth data */
549 +        if (pbuf != NULL)
550 +                free((char *)pbuf);             /* free our portal buffer */
551   }
552  
553  
# Line 588 | Line 573 | int    dx, dy;
573   FVECT   direc;
574   {
575          GLfloat gldepth;
591        GLubyte glcolor[4];
576          double  dist;
577  
578          if (dx<0 | dx>=odev.hres | dy<0 | dy>=odev.vres)
# Line 598 | Line 582 | FVECT  direc;
582          else {
583                  glReadPixels(dx,dy, 1,1, GL_DEPTH_COMPONENT,
584                                  GL_FLOAT, &gldepth);
601                if (gmPortals) {
602                        glReadPixels(dx,dy, 1,1, GL_RGBA,
603                                        GL_UNSIGNED_BYTE, glcolor);
604                        if (isportal(glcolor))
605                                return(FHUGE);
606                }
585                  dist = mapdepth(gldepth);
586          }
587          if (dist >= .99*FHUGE)
# Line 714 | Line 692 | int    fore;
692          glPushAttrib(GL_LIGHTING_BIT|GL_ENABLE_BIT);
693          glDisable(GL_LIGHTING);
694          if (fore)
695 <                glColor3ub(0, 255, 255);
695 >                glColor3ub(4, 250, 250);
696          else
697                  glColor3ub(0, 0, 0);
698          glBegin(GL_LINES);              /* draw each grid line */
# Line 837 | Line 815 | XButtonPressedEvent    *ebut;
815   #ifdef DOBJ
816                  ndrawn += dobj_render();
817   #endif
840                if (ndrawn && gmPortals)
841                        gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP);
818                  popright();
819   #endif
820                                          /* redraw octrees */
# Line 846 | Line 822 | XButtonPressedEvent    *ebut;
822   #ifdef DOBJ
823                  ndrawn += dobj_render();        /* redraw objects */
824   #endif
849                if (ndrawn && gmPortals)
850                        gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP);
825                  glXSwapBuffers(ourdisplay, gwind);
826                  if (!ndrawn)
827                          sleep(1);       /* for reasonable interaction */
# Line 876 | Line 850 | register VIEW  *vp;
850                  dev_zmax = 100.;
851          } else {
852                  dev_zmin = 0.5*depthlim[0];
853 <                dev_zmax = 1.75*depthlim[1];
853 >                dev_zmax = 2.0*depthlim[1];
854                  if (dev_zmin > dev_zmax/5.)
855                          dev_zmin = dev_zmax/5.;
856          }
# Line 946 | Line 920 | static
920   wipeclean()                     /* prepare for redraw */
921   {
922          glDrawBuffer(GL_BACK);          /* use double-buffer mode */
923 +        glReadBuffer(GL_BACK);
924                                          /* clear buffers */
925   #ifdef STEREO
926          setstereobuf(STEREO_BUFFER_RIGHT);
# Line 958 | Line 933 | wipeclean()                    /* prepare for redraw */
933                          (VWCHANGE|VWSTEADY)) {  /* clear samples if new */
934                  odClean();
935                  viewflags &= ~VWCHANGE;         /* change noted */
936 <        }
936 >        } else if (viewflags & VWSTEADY)
937 >                odRedrawAll();
938          setglpersp(&odev.v);            /* reset view & clipping planes */
939   }
940  
# Line 1009 | Line 985 | register XKeyPressedEvent  *ekey;
985                  inpresflags |= DFL(DC_RESUME);
986                  return;
987          case CTRL('R'):                 /* redraw screen */
988 <                odRemap(0);
988 >                odRemap(0);                     /* new tone mapping */
989                  glClear(GL_DEPTH_BUFFER_BIT);
990   #ifdef STEREO
991                  setstereobuf(STEREO_BUFFER_RIGHT);
# Line 1022 | Line 998 | register XKeyPressedEvent  *ekey;
998                          return;
999                  XRaiseWindow(ourdisplay, gwind);
1000                  XFlush(ourdisplay);
1001 <                sleep(1);
1002 <                wipeclean();                    /* fresh display */
1027 <                odRemap(1);                     /* fresh tone mapping */
1001 >                sleep(1);                       /* wait for restacking */
1002 >                dev_clear();                    /* clear display and samples */
1003                  dev_flush();                    /* draw octrees */
1004 +                odRemap(1);                     /* start fresh histogram */
1005                  inpresflags |= DFL(DC_REDRAW);  /* resend values from server */
1030                rayqleft = 0;                   /* hold off update */
1006                  return;
1007          case 'K':                       /* kill rtrace process(es) */
1008                  inpresflags |= DFL(DC_KILL);
# Line 1060 | Line 1035 | register XExposeEvent  *eexp;
1035          }
1036          xmin = eexp->x; xmax = eexp->x + eexp->width;
1037          ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y;
1038 +
1039 +        if (xmin <= 0 && xmax >= odev.hres-1 &&
1040 +                        ymin <= 0 && ymax >= odev.vres) {
1041 +                DCHECK(eexp->count, WARNING, "multiple clear in fixwindow");
1042 +                if (viewflags & VWORTHO)        /* workaround for... */
1043 +                        glDrawBuffer(GL_FRONT); /* ...GLX window mapping bug */
1044 +                glClear(GL_DEPTH_BUFFER_BIT);   /* clear the entire buffer */
1045 + #ifdef STEREO
1046 +                setstereobuf(STEREO_BUFFER_RIGHT);
1047 +                glClear(GL_DEPTH_BUFFER_BIT);
1048 +                setstereobuf(STEREO_BUFFER_LEFT);
1049 + #endif
1050 +                odRedrawAll();
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