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.26 by greg, Fri Jan 7 20:33:02 2005 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1998 Silicon Graphics, Inc. */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ SGI";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * OpenGL driver for holodeck display.
6   * Based on GLX driver using T-mesh.
# Line 20 | Line 17 | static char SCCSid[] = "$SunId$ SGI";
17   #endif
18   #endif
19  
23 #include "standard.h"
20  
21 < #include <sys/types.h>
21 > #include <time.h>
22   #include <GL/glx.h>
23   #include <GL/glu.h>
24   #ifdef STEREO
25   #include <X11/extensions/SGIStereo.h>
26   #endif
27  
28 + #include "standard.h"
29   #include "rhd_odraw.h"
30 + #include "rhdisp.h"
31 + #include "paths.h"
32   #ifdef DOBJ
33   #include "rhdobj.h"
34   #endif
# 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 80 | Line 82 | static char SCCSid[] = "$SunId$ SGI";
82  
83   struct driver   odev;                   /* global device driver structure */
84  
85 + TMstruct        *tmGlobal;              /* global tone-mapping structure */
86 +
87   char odev_args[64];                     /* command arguments */
88  
89   static GLfloat  *depthbuffer = NULL;    /* depth buffer */
# Line 112 | Line 116 | static int     inpresflags;            /* input result flags */
116  
117   static int      viewflags;              /* what's happening with view */
118  
119 + /*
120   static int  resizewindow(), getevent(), getkey(), moveview(), wipeclean(),
121                  xferdepth(), freedepth(), setglortho(),
122                  setglpersp(), getframe(), getmove(), fixwindow(), mytmflags();
123  
124   static double   getdistance();
125 + */
126 + static void checkglerr(char *where);
127 + static void xferdepth(void);
128 + static void freedepth(void);
129 + static double getdistance(int dx, int dy, FVECT direc);
130 + static int mytmflags(void);
131 + static void getevent(void);
132 + static void draw3dline(register FVECT wp[2]);
133 + static void draw_grids(int fore);
134 + static int moveview(int dx, int dy, int mov, int orb);
135 + static void getframe(XButtonPressedEvent *ebut);
136 + static void getmove(XButtonPressedEvent *ebut);
137 + static void getkey(register XKeyPressedEvent *ekey);
138 + static void fixwindow(register XExposeEvent *eexp);
139 + static void resizewindow(register XConfigureEvent *ersz);
140 + static void waitabit(void);
141 + static void setglpersp(void);
142 + static void setglortho(void);
143 + static void wipeclean(void);
144  
145 +
146   #ifdef STEREO
147 < static int  pushright(), popright();
147 > static void pushright(void);
148 > static void popright(void);
149   #endif
150  
151   extern int      gmPortals;      /* GL portal list id */
# Line 127 | Line 153 | extern int     gmPortals;      /* GL portal list id */
153   extern time_t   time();
154  
155  
156 + extern void
157   dev_open(id)                    /* initialize GLX driver */
158   char  *id;
159   {
# Line 184 | Line 211 | char  *id;
211                                  &myprims[BLU][CIEX],&myprims[BLU][CIEY],
212                                  &myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6)
213                  dpri = myprims;
214 <        if (tmInit(mytmflags(), dpri, gamval) == NULL)
214 >        tmGlobal = tmInit(mytmflags(), dpri, gamval);
215 >        if (tmGlobal == NULL)
216                  error(SYSTEM, "not enough memory in dev_open");
217                                          /* open window */
218          ourwinattr.background_pixel = ourblack;
# Line 231 | Line 259 | char  *id;
259          glDisable(GL_CULL_FACE);
260          glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
261          glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
262 +        glPixelStorei(GL_PACK_ALIGNMENT, 1);
263 +        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
264                                          /* figure out sensible view */
265          pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) /
266                          DisplayWidth(ourdisplay, ourscreen);
# Line 241 | Line 271 | char  *id;
271          setstereobuf(STEREO_BUFFER_LEFT);
272   #endif
273          checkglerr("setting rendering parameters");
274 <        copystruct(&odev.v, &stdview);
274 >        odev.v = stdview;
275          odev.v.type = VT_PER;
276          viewflags = VWSTEADY;           /* view starts static */
277                                          /* map the window */
278          XMapWindow(ourdisplay, gwind);
279          dev_input();                    /* sets size and view angles */
280          if (!odInit(DisplayWidth(ourdisplay,ourscreen) *
281 <                        DisplayHeight(ourdisplay,ourscreen) / 4))
281 >                        DisplayHeight(ourdisplay,ourscreen) / 3))
282                  error(SYSTEM, "insufficient memory for value storage");
283          odev.name = id;
284          odev.firstuse = 1;              /* can't recycle samples */
# Line 256 | Line 286 | char  *id;
286   }
287  
288  
289 < dev_close()                     /* close our display and free resources */
289 > extern void
290 > dev_close(void)                 /* close our display and free resources */
291   {
292   #ifdef DOBJ
293          dobj_cleanup();
# Line 271 | Line 302 | dev_close()                    /* close our display and free resources
302          gwind = 0;
303          XCloseDisplay(ourdisplay);
304          ourdisplay = NULL;
305 <        tmDone(NULL);
305 >        tmDone(tmGlobal);
306          odev.v.type = 0;
307          odev.hres = odev.vres = 0;
308          odev.ifd = -1;
309   }
310  
311  
312 < dev_clear()                     /* clear our representation */
312 > extern void
313 > dev_clear(void)                 /* clear our representation */
314   {
315 <        wipeclean();
315 >        viewflags |= VWCHANGE;          /* pretend our view has changed */
316 >        wipeclean();                    /* clean off display and samples */
317 >        dev_flush();                    /* redraw geometry & get depth */
318          rayqleft = 0;                   /* hold off update */
319   }
320  
321  
322 < int
323 < dev_view(nv)                    /* assign new driver view */
324 < register VIEW   *nv;
322 > extern int
323 > dev_view(                       /* assign new driver view */
324 >        register VIEW   *nv
325 > )
326   {
292        double  d;
293
327          if (nv->type != VT_PER ||               /* check view legality */
328                          nv->horiz > 160. || nv->vert > 160.) {
329                  error(COMMAND, "illegal view type/angle");
# Line 326 | Line 359 | register VIEW  *nv;
359                          XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres);
360                          dev_input();    /* get resize event */
361                  }
362 <                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
362 >                odev.v = *nv;   /* setview() already called */
363                  viewflags |= VWCHANGE;
364          }
365 + #ifdef STEREO
366 +        vwright = *nv;
367 +        d = eyesepdist / sqrt(nv->hn2);
368 +        VSUM(vwright.vp, nv->vp, nv->hvec, d);
369 +        /* setview(&vwright);   -- Unnecessary */
370 + #endif
371          wipeclean();
372          return(1);
373   }
374  
375  
376 < dev_section(gfn, pfn)           /* add octree for geometry rendering */
377 < char    *gfn, *pfn;
376 > extern void
377 > dev_section(            /* add octree for geometry rendering */
378 >        char    *gfn,
379 >        char    *pfn
380 > )
381   {
346        extern char     *index();
347        char    *cp;
348
382          if (gfn == NULL) {
383                  gmEndGeom();
384                  gmEndPortal();
# Line 365 | Line 398 | char   *gfn, *pfn;
398   }
399  
400  
401 < dev_auxcom(cmd, args)           /* process an auxiliary command */
402 < char    *cmd, *args;
401 > extern void
402 > dev_auxcom(             /* process an auxiliary command */
403 >        char    *cmd,
404 >        char    *args
405 > )
406   {
407   #ifdef DOBJ
408 <        if (dobj_command(cmd, args) >= 0)
408 >        int     vischange;
409 >
410 >        if ((vischange = dobj_command(cmd, args)) >= 0) {
411 >                if (vischange) {
412 >                        imm_mode = beam_sync(1) > 0;
413 >                        dev_clear();
414 >                }
415                  return;
416 +        }
417   #endif
418          sprintf(errmsg, "%s: unknown command", cmd);
419          error(COMMAND, errmsg);
420   }
421  
422  
423 < VIEW *
424 < dev_auxview(n, hvres)           /* return nth auxiliary view */
425 < int     n;
426 < int     hvres[2];
423 > extern VIEW *
424 > dev_auxview(            /* return nth auxiliary view */
425 >        int     n,
426 >        int     hvres[2]
427 > )
428   {
429          hvres[0] = odev.hres; hvres[1] = odev.vres;
430          if (n == 0)
# Line 393 | Line 437 | int    hvres[2];
437   }
438  
439  
440 < int
441 < dev_input()                     /* get X11 input */
440 > extern int
441 > dev_input(void)                 /* get X11 input */
442   {
443          inpresflags = 0;
444  
# Line 409 | Line 453 | dev_input()                    /* get X11 input */
453   }
454  
455  
456 < dev_value(c, d, p)              /* add a pixel value to our texture */
457 < COLR    c;
458 < FVECT   d, p;
456 > extern void
457 > dev_value(              /* add a pixel value to our texture */
458 >        COLR    c,
459 >        FVECT   d,
460 >        FVECT   p
461 > )
462   {
463   #ifdef DOBJ
464          if (dobj_lightsamp != NULL) {   /* in light source sampling */
# Line 425 | Line 472 | FVECT  d, p;
472   }
473  
474  
475 < int
476 < dev_flush()                     /* flush output as appropriate */
475 > extern int
476 > dev_flush(void)                 /* flush output as appropriate */
477   {
478          int     ndrawn;
479  
# Line 472 | Line 519 | dev_flush()                    /* flush output as appropriate */
519   }
520  
521  
522 < checkglerr(where)               /* check for GL or GLU error */
523 < char    *where;
522 > static void
523 > checkglerr(             /* check for GL or GLU error */
524 >        char    *where
525 > )
526   {
527          register GLenum errcode;
528  
# Line 485 | Line 534 | char   *where;
534   }
535  
536  
537 < static
538 < xferdepth()                     /* load and clear depth buffer */
537 > static void
538 > xferdepth(void)                 /* load and clear depth buffer */
539   {
540          register GLfloat        *dbp;
541          register GLubyte        *pbuf;
# Line 502 | Line 551 | xferdepth()                    /* load and clear depth buffer */
551          }
552                                  /* allocate alpha buffer for portals */
553          if (gmPortals)
554 <                pbuf = (GLubyte *)malloc(odev.hres*odev.vres *
506 <                                (4*sizeof(GLubyte)));
554 >                pbuf = (GLubyte *)malloc(odev.hres*odev.vres*sizeof(GLubyte));
555          else
556                  pbuf = NULL;
557   #ifdef STEREO
558 <        setstereobuf(STEREO_BUFFER_RIGHT);
558 >        pushright();
559          glReadPixels(0, 0, odev.hres, odev.vres,
560                          GL_DEPTH_COMPONENT, GL_FLOAT, depthright);
561          if (pbuf != NULL) {
562                  glClear(GL_COLOR_BUFFER_BIT);
563                  gmDrawPortals(0xff, -1, -1, -1);
564                  glReadPixels(0, 0, odev.hres, odev.vres,
565 <                                GL_RGBA, GL_UNSIGNED_BYTE, pbuf);
565 >                                GL_RED, GL_UNSIGNED_BYTE, pbuf);
566          }
567          for (dbp = depthright + odev.hres*odev.vres; dbp-- > depthright; )
568 <                if (pbuf != NULL && pbuf[4*(dbp-depthright)]&0x40)
568 >                if (pbuf != NULL && pbuf[dbp-depthright]&0x40)
569                          *dbp = FHUGE;
570                  else
571                          *dbp = mapdepth(*dbp);
572          glClear(GL_DEPTH_BUFFER_BIT);
525        setstereobuf(STEREO_BUFFER_LEFT);
573          odDepthMap(1, depthright);
574 +        popright();
575   #endif
576                                  /* read back depth buffer */
577          glReadPixels(0, 0, odev.hres, odev.vres,
# Line 532 | Line 580 | xferdepth()                    /* load and clear depth buffer */
580                  glClear(GL_COLOR_BUFFER_BIT);           /* find portals */
581                  gmDrawPortals(0xff, -1, -1, -1);
582                  glReadPixels(0, 0, odev.hres, odev.vres,
583 <                                GL_RGBA, GL_UNSIGNED_BYTE, pbuf);
583 >                                GL_RED, GL_UNSIGNED_BYTE, pbuf);
584 > #ifdef DEBUG
585 >                glXSwapBuffers(ourdisplay, gwind);
586 > #endif
587          }
588          for (dbp = depthbuffer + odev.hres*odev.vres; dbp-- > depthbuffer; )
589 <                if (pbuf != NULL && pbuf[4*(dbp-depthbuffer)]&0x40)
589 >                if (pbuf != NULL && pbuf[dbp-depthbuffer]&0x40)
590                          *dbp = FHUGE;
591                  else
592                          *dbp = mapdepth(*dbp);
593          glClear(GL_DEPTH_BUFFER_BIT);           /* clear system depth buffer */
594          odDepthMap(0, depthbuffer);             /* transfer depth data */
595          if (pbuf != NULL)
596 <                free((char *)pbuf);             /* free our portal buffer */
596 >                free((void *)pbuf);             /* free our portal buffer */
597   }
598  
599  
600 < static
601 < freedepth()                             /* free recorded depth buffer */
600 > static void
601 > freedepth(void)                         /* free recorded depth buffer */
602   {
603          if (depthbuffer == NULL)
604                  return;
605   #ifdef STEREO
606          odDepthMap(1, NULL);
607 <        free((char *)depthright);
607 >        free((void *)depthright);
608          depthright = NULL;
609   #endif
610          odDepthMap(0, NULL);
611 <        free((char *)depthbuffer);
611 >        free((void *)depthbuffer);
612          depthbuffer = NULL;
613   }
614  
615  
616   static double
617 < getdistance(dx, dy, direc)      /* distance from fore plane along view ray */
618 < int     dx, dy;
619 < FVECT   direc;
617 > getdistance(    /* distance from fore plane along view ray */
618 >        int     dx,
619 >        int     dy,
620 >        FVECT   direc
621 > )
622   {
623          GLfloat gldepth;
624          double  dist;
625  
626 <        if (dx<0 | dx>=odev.hres | dy<0 | dy>=odev.vres)
626 >        if ((dx<0) | (dx>=odev.hres) | (dy<0) | (dy>=odev.vres))
627                  return(FHUGE);
628          if (depthbuffer != NULL)
629                  dist = depthbuffer[dy*odev.hres + dx];
630          else {
631                  glReadPixels(dx,dy, 1,1, GL_DEPTH_COMPONENT,
632                                  GL_FLOAT, &gldepth);
633 +                if (gldepth <= FTINY)
634 +                        return (FHUGE); /* call failed */
635                  dist = mapdepth(gldepth);
636          }
637          if (dist >= .99*FHUGE)
# Line 586 | Line 641 | FVECT  direc;
641  
642  
643   #ifdef STEREO
644 < static
645 < pushright()                     /* push on right view & buffer */
644 > static void
645 > pushright(void)                 /* push on right view & buffer */
646   {
647          double  d;
648  
# Line 603 | Line 658 | pushright()                    /* push on right view & buffer */
658   }
659  
660  
661 < static
662 < popright()                      /* pop off right view & buffer */
661 > static void
662 > popright(void)                  /* pop off right view & buffer */
663   {
664          if (viewflags & VWPERSP) {
665                  glMatrixMode(GL_MODELVIEW);
# Line 616 | Line 671 | popright()                     /* pop off right view & buffer */
671  
672  
673   static int
674 < mytmflags()                     /* figure out tone mapping flags */
674 > mytmflags(void)                 /* figure out tone mapping flags */
675   {
676          extern char     *progname;
677          register char   *cp, *tail;
# Line 640 | Line 695 | mytmflags()                    /* figure out tone mapping flags */
695   }
696  
697  
698 < static
699 < getevent()                      /* get next event */
698 > static void
699 > getevent(void)                  /* get next event */
700   {
701          XNextEvent(ourdisplay, levptr(XEvent));
702          switch (levptr(XEvent)->type) {
# Line 671 | Line 726 | getevent()                     /* get next event */
726   }
727  
728  
729 < static
730 < draw3dline(wp)                  /* draw 3d line in world coordinates */
731 < register FVECT  wp[2];
729 > static void
730 > draw3dline(                     /* draw 3d line in world coordinates */
731 >        register FVECT  wp[2]
732 > )
733   {
734          glVertex3d(wp[0][0], wp[0][1], wp[0][2]);
735          glVertex3d(wp[1][0], wp[1][1], wp[1][2]);
736   }
737  
738  
739 < static
740 < draw_grids(fore)                /* draw holodeck section grids */
741 < int     fore;
739 > static void
740 > draw_grids(             /* draw holodeck section grids */
741 >        int     fore
742 > )
743   {
744          glPushAttrib(GL_LIGHTING_BIT|GL_ENABLE_BIT);
745          glDisable(GL_LIGHTING);
# Line 698 | Line 755 | int    fore;
755   }
756  
757  
758 < static
759 < moveview(dx, dy, mov, orb)      /* move our view */
760 < int     dx, dy, mov, orb;
758 > static int
759 > moveview(       /* move our view */
760 >        int     dx,
761 >        int     dy,
762 >        int     mov,
763 >        int     orb
764 > )
765   {
766          VIEW    nv;
767          FVECT   odir, v1, wip;
768          double  d, d1;
708        register int    li;
769                                  /* start with old view */
770 <        copystruct(&nv, &odev.v);
770 >        nv = odev.v;
771                                  /* orient our motion */
772          if (viewray(v1, odir, &odev.v,
773                          (dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY)
# Line 753 | Line 813 | int    dx, dy, mov, orb;
813   }
814  
815  
816 < static
817 < getframe(ebut)                          /* get focus frame */
818 < XButtonPressedEvent     *ebut;
816 > static void
817 > getframe(                               /* get focus frame */
818 >        XButtonPressedEvent     *ebut
819 > )
820   {
821          int     startx = ebut->x, starty = ebut->y;
822          int     endx, endy;
# Line 763 | Line 824 | XButtonPressedEvent    *ebut;
824          XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent));
825          endx = levptr(XButtonReleasedEvent)->x;
826          endy = levptr(XButtonReleasedEvent)->y;
827 <        if (endx == startx | endy == starty) {
827 >        if ((endx == startx) | (endy == starty)) {
828                  XBell(ourdisplay, 0);
829                  return;
830          }
# Line 776 | Line 837 | XButtonPressedEvent    *ebut;
837   }
838  
839  
840 < static
841 < getmove(ebut)                           /* get view change */
781 < XButtonPressedEvent     *ebut;
840 > static void
841 > waitabit(void)                          /* pause a moment */
842   {
843 +        struct timespec ts;
844 +        ts.tv_sec = 0;
845 +        ts.tv_nsec = 100000000L;
846 +        nanosleep(&ts, NULL);
847 + }
848 +
849 +
850 + static void
851 + getmove(                                /* get view change */
852 +        XButtonPressedEvent     *ebut
853 + )
854 + {
855          int     movdir = MOVDIR(ebut->button);
856          int     movorb = MOVORB(ebut->state);
857          int     ndrawn;
# Line 790 | Line 862 | XButtonPressedEvent    *ebut;
862          XNoOp(ourdisplay);              /* makes sure we're not idle */
863  
864          viewflags &= ~VWSTEADY;         /* flag moving view */
865 <        setglpersp(&odev.v);            /* start us off in perspective */
865 >        setglpersp();                   /* start us off in perspective */
866          while (!XCheckMaskEvent(ourdisplay,
867                          ButtonReleaseMask, levptr(XEvent))) {
868 +                                        /* pause so as not to move too fast */
869 +                waitabit();
870                                          /* get cursor position */
871                  if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
872                                  &rootx, &rooty, &wx, &wy, &statemask))
# Line 831 | Line 905 | XButtonPressedEvent    *ebut;
905   }
906  
907  
908 < static
909 < setglpersp(vp)                  /* set perspective view in GL */
836 < register VIEW   *vp;
908 > static void
909 > setglpersp(void)                        /* set perspective view in GL */
910   {
911          double  d, xmin, xmax, ymin, ymax;
912          GLfloat vec[4];
# Line 845 | Line 918 | register VIEW  *vp;
918                  dev_zmax = 100.;
919          } else {
920                  dev_zmin = 0.5*depthlim[0];
921 <                dev_zmax = 1.75*depthlim[1];
921 >                dev_zmax = 1.25*depthlim[1];
922                  if (dev_zmin > dev_zmax/5.)
923                          dev_zmin = dev_zmax/5.;
924          }
# Line 853 | Line 926 | register VIEW  *vp;
926                  dev_zmin = odev.v.vfore;
927          if (odev.v.vaft > FTINY)
928                  dev_zmax = odev.v.vaft;
929 <        if (dev_zmin < dev_zmax/100.)
930 <                dev_zmin = dev_zmax/100.;
929 >        if (dev_zmin*500. < dev_zmax)
930 >                dev_zmin = dev_zmax/500.;
931          setzrat();
932          xmax = dev_zmin * tan(PI/180./2. * odev.v.horiz);
933          xmin = -xmax;
# Line 894 | Line 967 | register VIEW  *vp;
967   }
968  
969  
970 < static
971 < setglortho()                    /* set up orthographic view for cone drawing */
970 > static void
971 > setglortho(void)                        /* set up orthographic view for cone drawing */
972   {
973          glDrawBuffer(GL_FRONT);         /* use single-buffer mode */
974                                          /* set view matrix */
# Line 911 | Line 984 | setglortho()                   /* set up orthographic view for cone dr
984   }
985  
986  
987 < static
988 < wipeclean()                     /* prepare for redraw */
987 > static void
988 > wipeclean(void)                 /* prepare for redraw */
989   {
990          glDrawBuffer(GL_BACK);          /* use double-buffer mode */
991          glReadBuffer(GL_BACK);
# Line 928 | Line 1001 | wipeclean()                    /* prepare for redraw */
1001                          (VWCHANGE|VWSTEADY)) {  /* clear samples if new */
1002                  odClean();
1003                  viewflags &= ~VWCHANGE;         /* change noted */
1004 <        }
1005 <        setglpersp(&odev.v);            /* reset view & clipping planes */
1004 >        } else if (viewflags & VWSTEADY)
1005 >                odRedrawAll();
1006 >        setglpersp();                   /* reset view & clipping planes */
1007   }
1008  
1009  
1010 < static
1011 < getkey(ekey)                            /* get input key */
1012 < register XKeyPressedEvent  *ekey;
1010 > static void
1011 > getkey(                         /* get input key */
1012 >        register XKeyPressedEvent  *ekey
1013 > )
1014   {
1015          Window  rootw, childw;
1016          int     rootx, rooty, wx, wy;
# Line 979 | Line 1054 | register XKeyPressedEvent  *ekey;
1054                  inpresflags |= DFL(DC_RESUME);
1055                  return;
1056          case CTRL('R'):                 /* redraw screen */
1057 <                odRemap(0);
1057 >                odRemap(0);                     /* new tone mapping */
1058                  glClear(GL_DEPTH_BUFFER_BIT);
1059   #ifdef STEREO
1060                  setstereobuf(STEREO_BUFFER_RIGHT);
# Line 989 | Line 1064 | register XKeyPressedEvent  *ekey;
1064                  return;
1065          case CTRL('L'):                 /* refresh from server */
1066                  if (inpresflags & DFL(DC_REDRAW))
1067 <                        return;
1067 >                        return;                 /* already called */
1068                  XRaiseWindow(ourdisplay, gwind);
1069 <                XFlush(ourdisplay);
1070 <                sleep(1);
1071 <                wipeclean();                    /* fresh display */
1072 <                odRemap(1);                     /* fresh tone mapping */
998 <                dev_flush();                    /* draw octrees */
1069 >                XFlush(ourdisplay);             /* raise up window */
1070 >                sleep(1);                       /* wait for restacking */
1071 >                dev_clear();                    /* clear buffer and samples */
1072 >                odRemap(1);                     /* start fresh histogram */
1073                  inpresflags |= DFL(DC_REDRAW);  /* resend values from server */
1000                rayqleft = 0;                   /* hold off update */
1074                  return;
1075          case 'K':                       /* kill rtrace process(es) */
1076                  inpresflags |= DFL(DC_KILL);
# Line 1018 | Line 1091 | register XKeyPressedEvent  *ekey;
1091   }
1092  
1093  
1094 < static
1095 < fixwindow(eexp)                         /* repair damage to window */
1096 < register XExposeEvent  *eexp;
1094 > static void
1095 > fixwindow(                              /* repair damage to window */
1096 >        register XExposeEvent  *eexp
1097 > )
1098   {
1099          int     xmin, ymin, xmax, ymax;
1100  
1101 <        if (odev.hres == 0 | odev.vres == 0) {  /* first exposure */
1101 >        if ((odev.hres == 0) | (odev.vres == 0)) {      /* first exposure */
1102                  resizewindow((XConfigureEvent *)eexp);
1103                  return;
1104          }
1105          xmin = eexp->x; xmax = eexp->x + eexp->width;
1106          ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y;
1107 +
1108 +        if (xmin <= 0 && xmax >= odev.hres-1 &&
1109 +                        ymin <= 0 && ymax >= odev.vres) {
1110 +                DCHECK(eexp->count, WARNING, "multiple clear in fixwindow");
1111 +                wipeclean();                    /* make sure we're go */
1112 +                return;
1113 +        }
1114                                                  /* clear portion of depth */
1115          glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
1116          glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
# Line 1056 | Line 1137 | register XExposeEvent  *eexp;
1137   }
1138  
1139  
1140 < static
1141 < resizewindow(ersz)                      /* resize window */
1142 < register XConfigureEvent  *ersz;
1140 > static void
1141 > resizewindow(                   /* resize window */
1142 >        register XConfigureEvent  *ersz
1143 > )
1144   {
1145          glViewport(0, 0, ersz->width, ersz->height);
1146  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines