ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_glx.c
(Generate patch)

Comparing ray/src/hd/rhd_glx.c (file contents):
Revision 3.22 by gwlarson, Tue Aug 25 18:11:17 1998 UTC vs.
Revision 3.24 by gwlarson, Thu Dec 10 10:45:54 1998 UTC

# Line 21 | Line 21 | static char SCCSid[] = "$SunId$ SGI";
21   #endif
22  
23   #include "standard.h"
24 #include "rhd_sample.h"
24  
25   #include <sys/types.h>
26   #include <GL/glx.h>
# Line 29 | Line 28 | static char SCCSid[] = "$SunId$ SGI";
28   #ifdef STEREO
29   #include <X11/extensions/SGIStereo.h>
30   #endif
31 +
32 + #include "rhd_sample.h"
33   #ifdef DOBJ
34   #include "rhdobj.h"
35   #endif
# Line 36 | Line 37 | static char SCCSid[] = "$SunId$ SGI";
37   #include "x11icon.h"
38  
39   #ifndef RAYQLEN
40 < #define RAYQLEN         250             /* max. rays to queue before flush */
40 > #define RAYQLEN         1024            /* max. rays to queue before flush */
41   #endif
42  
43   #ifndef FEQ
# Line 45 | Line 46 | static char SCCSid[] = "$SunId$ SGI";
46  
47   #define GAMMA           1.4             /* default gamma correction */
48  
49 + #define FRAMESTATE(s)   (((s)&(ShiftMask|ControlMask))==(ShiftMask|ControlMask))
50 +
51   #define MOVPCT          7               /* percent distance to move /frame */
52   #define MOVDIR(b)       ((b)==Button1 ? 1 : (b)==Button2 ? 0 : -1)
53   #define MOVDEG          (-5)            /* degrees to orbit CW/down /frame */
# Line 74 | Line 77 | static char SCCSid[] = "$SunId$ SGI";
77  
78   struct driver   odev;                   /* global device driver structure */
79  
80 + char odev_args[64];                     /* command arguments */
81 +
82 + #ifdef STEREO
83   static VIEW     vwright;                /* right eye view */
84 + #endif
85  
86   static int      rayqleft = 0;           /* rays left to queue before flush */
87  
# Line 99 | Line 106 | static int     inpresflags;            /* input result flags */
106   static int      headlocked = 0;         /* lock vertical motion */
107  
108   static int  resizewindow(), getevent(), getkey(), moveview(), wipeclean(),
109 <                setglpersp(), getmove(), fixwindow(), mytmflags();
109 >                setglpersp(), getframe(), getmove(), fixwindow(), mytmflags();
110  
111   #ifdef STEREO
112   static int  pushright(), popright();
# Line 216 | Line 223 | char  *id;
223          pheight *= 2.;
224          setstereobuf(STEREO_BUFFER_LEFT);
225   #endif
226 +        checkglerr("setting rendering parameters");
227          copystruct(&odev.v, &stdview);
228          odev.v.type = VT_PER;
229                                          /* map the window */
# Line 390 | Line 398 | dev_flush()                    /* flush output */
398          if (mapped) {
399   #ifdef STEREO
400                  pushright();                    /* update right eye */
393                glClear(GL_DEPTH_BUFFER_BIT);
401                  smUpdate(&vwright, 100);
402   #ifdef DOBJ
403                  dobj_render();                  /* usually in foreground */
404   #endif
405                  popright();                     /* update left eye */
399                glClear(GL_DEPTH_BUFFER_BIT);
406   #endif
407                  smUpdate(&odev.v, 100);
408                  checkglerr("rendering mesh");
# Line 435 | Line 441 | pushright()                    /* push on right view */
441          glPushMatrix();
442          d = -eyesepdist / sqrt(odev.v.hn2);
443          glTranslated(d*odev.v.hvec[0], d*odev.v.hvec[1], d*odev.v.hvec[2]);
444 +        checkglerr("setting right view");
445   }
446  
447  
# Line 487 | Line 494 | getevent()                     /* get next event */
494                  getkey(levptr(XKeyPressedEvent));
495                  break;
496          case ButtonPress:
497 <                getmove(levptr(XButtonPressedEvent));
497 >                if (FRAMESTATE(levptr(XButtonPressedEvent)->state))
498 >                        getframe(levptr(XButtonPressedEvent));
499 >                else
500 >                        getmove(levptr(XButtonPressedEvent));
501                  break;
502          }
503   }
# Line 506 | Line 516 | static
516   draw_grids(fore)                /* draw holodeck section grids */
517   int     fore;
518   {
509        if (!mapped)
510                return;
519          if (fore)
520                  glColor4ub(0, 255, 255, 0);
521          else
# Line 515 | Line 523 | int    fore;
523          glBegin(GL_LINES);              /* draw each grid line */
524          gridlines(draw3dline);
525          glEnd();
526 +        checkglerr("drawing grid lines");
527   }
528  
529  
# Line 549 | Line 558 | int    dx, dy, mov, orb;
558                          return(0);      /* not on window */
559                  VCOPY(wip, rsL.wp[li]);
560   #endif
561 + #ifdef DEBUG
562 +                fprintf(stderr, "moveview: hit %s at (%f,%f,%f) (t=%f)\n",
563 +                                li < 0 ? "object" : "mesh",
564 +                                wip[0], wip[1], wip[2],
565 +                                (wip[0]-odev.v.vp[0])*odir[0] +
566 +                                (wip[1]-odev.v.vp[1])*odir[1] +
567 +                                (wip[2]-odev.v.vp[2])*odir[2]);
568 + #endif
569                  VSUM(odir, wip, odev.v.vp, -1.);
570          } else                  /* panning with constant viewpoint */
571                  VCOPY(nv.vdir, odir);
# Line 581 | Line 598 | int    dx, dy, mov, orb;
598  
599  
600   static
601 + getframe(ebut)                          /* get focus frame */
602 + XButtonPressedEvent     *ebut;
603 + {
604 +        int     startx = ebut->x, starty = ebut->y;
605 +        int     endx, endy;
606 +
607 +        XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent));
608 +        endx = levptr(XButtonReleasedEvent)->x;
609 +        endy = levptr(XButtonReleasedEvent)->y;
610 +        if (endx == startx | endy == starty) {
611 +                XBell(ourdisplay, 0);
612 +                return;
613 +        }
614 +        if (endx < startx) {register int c = endx; endx = startx; startx = c;}
615 +        if (endy < starty) {register int c = endy; endy = starty; starty = c;}
616 +        sprintf(odev_args, "%.3f %.3f %.3f %.3f",
617 +                        (startx+.5)/odev.hres, 1.-(endy+.5)/odev.vres,
618 +                        (endx+.5)/odev.hres, 1.-(starty+.5)/odev.vres);
619 +        inpresflags |= DFL(DC_FOCUS);
620 + }
621 +
622 +
623 + static
624   getmove(ebut)                           /* get view change */
625   XButtonPressedEvent     *ebut;
626   {
# Line 593 | Line 633 | XButtonPressedEvent    *ebut;
633          int     rootx, rooty, wx, wy;
634          unsigned int    statemask;
635  
636 <        XNoOp(ourdisplay);
636 >        XNoOp(ourdisplay);              /* makes sure we're not idle */
637  
638          lasttime = time(0); nframes = 0;
639          while (!XCheckMaskEvent(ourdisplay,
640                          ButtonReleaseMask, levptr(XEvent))) {
641 <
641 >                                        /* get cursor position */
642                  if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
643                                  &rootx, &rooty, &wx, &wy, &statemask))
644                          break;          /* on another screen */
645  
646                  draw_grids(0);          /* clear old grid lines */
647 + #ifdef STEREO
648 +                pushright(); draw_grids(0); popright();
649 + #endif
650 +                                        /* compute view motion */
651                  if (!moveview(wx, odev.vres-1-wy, movdir, movorb)) {
652                          sleep(1);
653                          lasttime++;
654 <                        continue;
654 >                        continue;       /* cursor in bad place */
655                  }
656 +                draw_grids(1);          /* redraw grid */
657   #ifdef STEREO
658                  pushright();
659                  draw_grids(1);
# Line 618 | Line 663 | XButtonPressedEvent    *ebut;
663   #endif
664                  popright();
665   #endif
666 <                draw_grids(1);
666 >                                        /* redraw mesh */
667                  smUpdate(&odev.v, qlevel);
668   #ifdef DOBJ
669 <                dobj_render();
669 >                dobj_render();          /* redraw object */
670   #endif
671                  glFlush();
672 <                checkglerr("moving view");
628 <                nframes++;
672 >                nframes++;              /* figure out good quality level */
673                  thistime = time(0);
674                  if (thistime - lasttime >= 3 ||
675                                  nframes > (int)(3*3*TARGETFPS)) {
# Line 690 | Line 734 | register VIEW  *vp;
734                  odev.v.vp[1] + odev.v.vdir[1],
735                  odev.v.vp[2] + odev.v.vdir[2],
736                  odev.v.vup[0], odev.v.vup[1], odev.v.vup[2]);
737 +        checkglerr("setting perspective view");
738   }
739  
740  
# Line 712 | Line 757 | static
757   getkey(ekey)                            /* get input key */
758   register XKeyPressedEvent  *ekey;
759   {
760 +        Window  rootw, childw;
761 +        int     rootx, rooty, wx, wy;
762 +        unsigned int    statemask;
763          int  n;
764          char    buf[8];
765  
# Line 734 | Line 782 | register XKeyPressedEvent  *ekey;
782          case 'v':                       /* spit out view */
783                  inpresflags |= DFL(DC_GETVIEW);
784                  return;
785 +        case 'f':                       /* frame view position */
786 +                if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
787 +                                &rootx, &rooty, &wx, &wy, &statemask))
788 +                        return;         /* on another screen */
789 +                sprintf(odev_args, "%.4f %.4f", (wx+.5)/odev.hres,
790 +                                1.-(wy+.5)/odev.vres);
791 +                inpresflags |= DFL(DC_FOCUS);
792 +                return;
793 +        case 'F':                       /* unfocus */
794 +                odev_args[0] = '\0';
795 +                inpresflags |= DFL(DC_FOCUS);
796 +                return;
797          case '\n':
798          case '\r':                      /* resume computation */
799                  inpresflags |= DFL(DC_RESUME);
# Line 744 | Line 804 | register XKeyPressedEvent  *ekey;
804          case CTRL('L'):                 /* refresh from server */
805                  if (inpresflags & DFL(DC_REDRAW))
806                          return;
807 +                setglpersp(&odev.v);            /* reset clipping planes */
808                  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
809 <                glDisable(GL_DEPTH_TEST);
809 >                glDisable(GL_DEPTH_TEST);       /* so grids will clear */
810                  draw_grids(1);
811   #ifdef STEREO
812                  pushright();
# Line 757 | Line 818 | register XKeyPressedEvent  *ekey;
818                  glFlush();
819                  smInit(rsL.max_samp);           /* get rid of old values */
820                  inpresflags |= DFL(DC_REDRAW);  /* resend values from server */
760                setglpersp(&odev.v);            /* reset clipping planes */
821                  rayqleft = 0;                   /* hold off update */
822                  return;
823          case 'K':                       /* kill rtrace process(es) */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines