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.5 by gwlarson, Mon Dec 21 15:31:49 1998 UTC vs.
Revision 3.6 by gwlarson, Mon Dec 21 19:17:28 1998 UTC

# Line 37 | Line 37 | static char SCCSid[] = "$SunId$ SGI";
37   #include "x11icon.h"
38  
39   #ifndef RAYQLEN
40 < #define RAYQLEN         10240           /* max. rays to queue before flush */
40 > #define RAYQLEN         50000           /* max. rays to queue before flush */
41   #endif
42  
43   #ifndef PORTALP
# Line 142 | Line 142 | char  *id;
142          extern char     *getenv();
143          static RGBPRIMS myprims = STDPRIMS;
144   #if (PORTALP<0)
145 <        static int      atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8,
146 <                                GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8,
147 <                                GLX_DEPTH_SIZE,15, None};
145 >        static int      atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
146 >                                GLX_RED_SIZE,8, GLX_GREEN_SIZE,8,
147 >                                GLX_BLUE_SIZE,8, GLX_DEPTH_SIZE,15, None};
148 >        static int      atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
149 >                                GLX_RED_SIZE,4, GLX_GREEN_SIZE,4,
150 >                                GLX_BLUE_SIZE,4, GLX_DEPTH_SIZE,15, None};
151   #else
152 <        static int      atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8,
153 <                                GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8,
154 <                                GLX_ALPHA_SIZE,2, GLX_DEPTH_SIZE,15, None};
152 >        static int      atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
153 >                                GLX_RED_SIZE,8, GLX_GREEN_SIZE,8,
154 >                                GLX_BLUE_SIZE,8, GLX_ALPHA_SIZE,2,
155 >                                GLX_DEPTH_SIZE,15, None};
156 >        static int      atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER,
157 >                                GLX_RED_SIZE,4, GLX_GREEN_SIZE,4,
158 >                                GLX_BLUE_SIZE,4, GLX_ALPHA_SIZE,2,
159 >                                GLX_DEPTH_SIZE,15, None};
160   #endif
161          char    *ev;
162          double  gamval = GAMMA;
# Line 180 | Line 188 | char  *id;
188   #endif
189                                          /* find a usable visual */
190          ourvinf = glXChooseVisual(ourdisplay, ourscreen, atlBest);
191 +        if (ourvinf == NULL)
192 +                ourvinf = glXChooseVisual(ourdisplay, ourscreen, atlOK);
193          CHECK(ourvinf==NULL, USER, "no suitable visuals available");
194                                          /* get a context */
195          gctx = glXCreateContext(ourdisplay, ourvinf, NULL, GL_TRUE);
# Line 236 | Line 246 | char  *id;
246          glXMakeCurrent(ourdisplay, gwind, gctx);
247          glEnable(GL_DEPTH_TEST);
248          glDepthFunc(GL_LEQUAL);
249 <        glDisable(GL_DITHER);
249 >        glEnable(GL_DITHER);
250          glFrontFace(GL_CCW);
251          glDisable(GL_CULL_FACE);
252          glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
# Line 345 | Line 355 | register VIEW  *nv;
355                  VSUM(vwright.vp, nv->vp, nv->hvec, d);
356                  /* setview(&vwright);   -- Unnecessary */
357   #endif
358 <        } else
349 <                viewsteady = 1;
358 >        }
359          wipeclean();
360          return(1);
361   }
# Line 449 | Line 458 | dev_flush()                    /* flush output as appropriate */
458   #ifdef DOBJ
459                  ndrawn += dobj_render();
460   #endif
461 <                if (ndrawn)
462 <                        gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP);
461 >                if (ndrawn && gmPortals)
462 >                        gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP);
463                  checkglerr("rendering right eye");
464                  popright();                     /* draw left eye */
465   #endif
# Line 458 | Line 467 | dev_flush()                    /* flush output as appropriate */
467   #ifdef DOBJ
468                  ndrawn += dobj_render();
469   #endif
470 <                if (ndrawn)
471 <                        gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP);
470 >                if (ndrawn && gmPortals)
471 >                        gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP);
472 >                glXSwapBuffers(ourdisplay, gwind);
473                  checkglerr("rendering base view");
474          }
475          if (mapped && viewsteady)
# Line 474 | Line 484 | dev_flush()                    /* flush output as appropriate */
484                          popright();
485   #endif
486                          odUpdate(0);            /* draw left eye */
487 +                        glFlush();              /* flush OpenGL */
488                  }
478        glFlush();                              /* flush OpenGL */
489          rayqleft = RAYQLEN;
490                                          /* flush X11 and return # pending */
491          return(odev.inpready = XPending(ourdisplay));
# Line 512 | Line 522 | xferdepth()                    /* load and clear depth buffer */
522          }
523                                  /* allocate alpha buffer for portals */
524          if (gmPortals)
525 <                cbuf = (GLubyte *)malloc(odev.hres*odev.vres*
525 >                cbuf = (GLubyte *)malloc(odev.hres*odev.vres *
526                                                          (4*sizeof(GLubyte)));
527          else
528                  cbuf = NULL;
# Line 821 | Line 831 | XButtonPressedEvent    *ebut;
831   #ifdef DOBJ
832                  ndrawn += dobj_render();
833   #endif
834 <                if (ndrawn)
835 <                        gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP);
834 >                if (ndrawn && gmPortals)
835 >                        gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP);
836                  popright();
837   #endif
838                                          /* redraw octrees */
# Line 830 | Line 840 | XButtonPressedEvent    *ebut;
840   #ifdef DOBJ
841                  ndrawn += dobj_render();        /* redraw objects */
842   #endif
843 <                if (ndrawn)
843 >                if (ndrawn && gmPortals)
844                          gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP);
845 <                glFlush();
846 <                if (!ndrawn) {
845 >                glXSwapBuffers(ourdisplay, gwind);
846 >                if (!ndrawn)
847                          sleep(1);       /* for reasonable interaction */
838 #ifdef STEREO
839                        pushright();
840                        draw_grids(0);
841                        popright();
842 #endif
843                        draw_grids(0);
844                }
848          }
849          if (!(inpresflags & DFL(DC_SETVIEW))) { /* do final motion */
850                  movdir = MOVDIR(levptr(XButtonReleasedEvent)->button);
# Line 849 | Line 852 | XButtonPressedEvent    *ebut;
852                  wy = levptr(XButtonReleasedEvent)->y;
853                  moveview(wx, odev.vres-1-wy, movdir, movorb);
854          }
855 +        viewsteady = 1;                 /* done goofing around */
856   }
857  
858  
# Line 917 | Line 921 | register VIEW  *vp;
921   static
922   setglortho()                    /* set up orthographic view for cone drawing */
923   {
924 +        glDrawBuffer(GL_FRONT);         /* use single-buffer mode */
925                                          /* set view matrix */
926          glMatrixMode(GL_PROJECTION);
927          glLoadIdentity();
# Line 932 | Line 937 | setglortho()                   /* set up orthographic view for cone dr
937   static
938   wipeclean()                     /* prepare for redraw */
939   {
940 <                                        /* clear depth buffer */
940 >        glDrawBuffer(GL_BACK);          /* use double-buffer mode */
941 >                                        /* clear buffers */
942   #ifdef STEREO
943          setstereobuf(STEREO_BUFFER_RIGHT);
944 <        glClear(GL_DEPTH_BUFFER_BIT);
944 >        glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
945          setstereobuf(STEREO_BUFFER_LEFT);
946   #endif
947 <        glClear(GL_DEPTH_BUFFER_BIT);
947 >        glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
948 >        freedepth();
949          if (viewsteady)                 /* clear samples if steady */
950                  odClean();
944        freedepth();
951          setglpersp(&odev.v);            /* reset view & clipping planes */
952   }
953  
# Line 993 | Line 999 | register XKeyPressedEvent  *ekey;
999                  return;
1000          case CTRL('R'):                 /* redraw screen */
1001                  odRemap(0);
1002 <                glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
1002 >                glClear(GL_DEPTH_BUFFER_BIT);
1003   #ifdef STEREO
1004                  setstereobuf(STEREO_BUFFER_RIGHT);
1005 <                glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
1005 >                glClear(GL_DEPTH_BUFFER_BIT);
1006                  setstereobuf(STEREO_BUFFER_LEFT);
1007   #endif
1008                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines