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.23 by greg, Fri Sep 19 18:33:05 2003 UTC vs.
Revision 3.24 by schorsch, Thu Jan 1 11:21:55 2004 UTC

# Line 17 | Line 17 | static const char      RCSid[] = "$Id$";
17   #endif
18   #endif
19  
20 #include "standard.h"
20  
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 #include <time.h>
27  
28 + #include "standard.h"
29   #include "rhd_odraw.h"
30 + #include "rhdisp.h"
31   #ifdef DOBJ
32   #include "rhdobj.h"
33   #endif
# Line 112 | Line 113 | static int     inpresflags;            /* input result flags */
113  
114   static int      viewflags;              /* what's happening with view */
115  
116 + /*
117   static int  resizewindow(), getevent(), getkey(), moveview(), wipeclean(),
118                  xferdepth(), freedepth(), setglortho(),
119                  setglpersp(), getframe(), getmove(), fixwindow(), mytmflags();
120  
121   static double   getdistance();
122 + */
123 + static void checkglerr(char *where);
124 + static void xferdepth(void);
125 + static void freedepth(void);
126 + static double getdistance(int dx, int dy, FVECT direc);
127 + static int mytmflags(void);
128 + static void getevent(void);
129 + static void draw3dline(register FVECT wp[2]);
130 + static void draw_grids(int fore);
131 + static int moveview(int dx, int dy, int mov, int orb);
132 + static void getframe(XButtonPressedEvent *ebut);
133 + static void getmove(XButtonPressedEvent *ebut);
134 + static void getkey(register XKeyPressedEvent *ekey);
135 + static void fixwindow(register XExposeEvent *eexp);
136 + static void resizewindow(register XConfigureEvent *ersz);
137 + static void waitabit(void);
138 + static void setglpersp(void);
139 + static void setglortho(void);
140 + static void wipeclean(void);
141  
142 +
143   #ifdef STEREO
144 < static int  pushright(), popright();
144 > static void pushright(void);
145 > static void popright(void);
146   #endif
147  
148   extern int      gmPortals;      /* GL portal list id */
# Line 127 | Line 150 | extern int     gmPortals;      /* GL portal list id */
150   extern time_t   time();
151  
152  
153 + extern void
154   dev_open(id)                    /* initialize GLX driver */
155   char  *id;
156   {
# Line 258 | Line 282 | char  *id;
282   }
283  
284  
285 < dev_close()                     /* close our display and free resources */
285 > extern void
286 > dev_close(void)                 /* close our display and free resources */
287   {
288   #ifdef DOBJ
289          dobj_cleanup();
# Line 280 | Line 305 | dev_close()                    /* close our display and free resources
305   }
306  
307  
308 < dev_clear()                     /* clear our representation */
308 > extern void
309 > dev_clear(void)                 /* clear our representation */
310   {
311          viewflags |= VWCHANGE;          /* pretend our view has changed */
312          wipeclean();                    /* clean off display and samples */
# Line 289 | Line 315 | dev_clear()                    /* clear our representation */
315   }
316  
317  
318 < int
319 < dev_view(nv)                    /* assign new driver view */
320 < register VIEW   *nv;
318 > extern int
319 > dev_view(                       /* assign new driver view */
320 >        register VIEW   *nv
321 > )
322   {
296        double  d;
297
323          if (nv->type != VT_PER ||               /* check view legality */
324                          nv->horiz > 160. || nv->vert > 160.) {
325                  error(COMMAND, "illegal view type/angle");
# Line 344 | Line 369 | register VIEW  *nv;
369   }
370  
371  
372 < dev_section(gfn, pfn)           /* add octree for geometry rendering */
373 < char    *gfn, *pfn;
372 > extern void
373 > dev_section(            /* add octree for geometry rendering */
374 >        char    *gfn,
375 >        char    *pfn
376 > )
377   {
350        char    *cp;
351
378          if (gfn == NULL) {
379                  gmEndGeom();
380                  gmEndPortal();
# Line 368 | Line 394 | char   *gfn, *pfn;
394   }
395  
396  
397 < dev_auxcom(cmd, args)           /* process an auxiliary command */
398 < char    *cmd, *args;
397 > extern void
398 > dev_auxcom(             /* process an auxiliary command */
399 >        char    *cmd,
400 >        char    *args
401 > )
402   {
403   #ifdef DOBJ
404          int     vischange;
# Line 387 | Line 416 | char   *cmd, *args;
416   }
417  
418  
419 < VIEW *
420 < dev_auxview(n, hvres)           /* return nth auxiliary view */
421 < int     n;
422 < int     hvres[2];
419 > extern VIEW *
420 > dev_auxview(            /* return nth auxiliary view */
421 >        int     n,
422 >        int     hvres[2]
423 > )
424   {
425          hvres[0] = odev.hres; hvres[1] = odev.vres;
426          if (n == 0)
# Line 403 | Line 433 | int    hvres[2];
433   }
434  
435  
436 < int
437 < dev_input()                     /* get X11 input */
436 > extern int
437 > dev_input(void)                 /* get X11 input */
438   {
439          inpresflags = 0;
440  
# Line 419 | Line 449 | dev_input()                    /* get X11 input */
449   }
450  
451  
452 < dev_value(c, d, p)              /* add a pixel value to our texture */
453 < COLR    c;
454 < FVECT   d, p;
452 > extern void
453 > dev_value(              /* add a pixel value to our texture */
454 >        COLR    c,
455 >        FVECT   d,
456 >        FVECT   p
457 > )
458   {
459   #ifdef DOBJ
460          if (dobj_lightsamp != NULL) {   /* in light source sampling */
# Line 435 | Line 468 | FVECT  d, p;
468   }
469  
470  
471 < int
472 < dev_flush()                     /* flush output as appropriate */
471 > extern int
472 > dev_flush(void)                 /* flush output as appropriate */
473   {
474          int     ndrawn;
475  
# Line 482 | Line 515 | dev_flush()                    /* flush output as appropriate */
515   }
516  
517  
518 < checkglerr(where)               /* check for GL or GLU error */
519 < char    *where;
518 > static void
519 > checkglerr(             /* check for GL or GLU error */
520 >        char    *where
521 > )
522   {
523          register GLenum errcode;
524  
# Line 495 | Line 530 | char   *where;
530   }
531  
532  
533 < static
534 < xferdepth()                     /* load and clear depth buffer */
533 > static void
534 > xferdepth(void)                 /* load and clear depth buffer */
535   {
536          register GLfloat        *dbp;
537          register GLubyte        *pbuf;
# Line 558 | Line 593 | xferdepth()                    /* load and clear depth buffer */
593   }
594  
595  
596 < static
597 < freedepth()                             /* free recorded depth buffer */
596 > static void
597 > freedepth(void)                         /* free recorded depth buffer */
598   {
599          if (depthbuffer == NULL)
600                  return;
# Line 575 | Line 610 | freedepth()                            /* free recorded depth buffer */
610  
611  
612   static double
613 < getdistance(dx, dy, direc)      /* distance from fore plane along view ray */
614 < int     dx, dy;
615 < FVECT   direc;
613 > getdistance(    /* distance from fore plane along view ray */
614 >        int     dx,
615 >        int     dy,
616 >        FVECT   direc
617 > )
618   {
619          GLfloat gldepth;
620          double  dist;
621  
622 <        if (dx<0 | dx>=odev.hres | dy<0 | dy>=odev.vres)
622 >        if ((dx<0) | (dx>=odev.hres) | (dy<0) | (dy>=odev.vres))
623                  return(FHUGE);
624          if (depthbuffer != NULL)
625                  dist = depthbuffer[dy*odev.hres + dx];
# Line 600 | Line 637 | FVECT  direc;
637  
638  
639   #ifdef STEREO
640 < static
641 < pushright()                     /* push on right view & buffer */
640 > static void
641 > pushright(void)                 /* push on right view & buffer */
642   {
643          double  d;
644  
# Line 617 | Line 654 | pushright()                    /* push on right view & buffer */
654   }
655  
656  
657 < static
658 < popright()                      /* pop off right view & buffer */
657 > static void
658 > popright(void)                  /* pop off right view & buffer */
659   {
660          if (viewflags & VWPERSP) {
661                  glMatrixMode(GL_MODELVIEW);
# Line 630 | Line 667 | popright()                     /* pop off right view & buffer */
667  
668  
669   static int
670 < mytmflags()                     /* figure out tone mapping flags */
670 > mytmflags(void)                 /* figure out tone mapping flags */
671   {
672          extern char     *progname;
673          register char   *cp, *tail;
# Line 654 | Line 691 | mytmflags()                    /* figure out tone mapping flags */
691   }
692  
693  
694 < static
695 < getevent()                      /* get next event */
694 > static void
695 > getevent(void)                  /* get next event */
696   {
697          XNextEvent(ourdisplay, levptr(XEvent));
698          switch (levptr(XEvent)->type) {
# Line 685 | Line 722 | getevent()                     /* get next event */
722   }
723  
724  
725 < static
726 < draw3dline(wp)                  /* draw 3d line in world coordinates */
727 < register FVECT  wp[2];
725 > static void
726 > draw3dline(                     /* draw 3d line in world coordinates */
727 >        register FVECT  wp[2]
728 > )
729   {
730          glVertex3d(wp[0][0], wp[0][1], wp[0][2]);
731          glVertex3d(wp[1][0], wp[1][1], wp[1][2]);
732   }
733  
734  
735 < static
736 < draw_grids(fore)                /* draw holodeck section grids */
737 < int     fore;
735 > static void
736 > draw_grids(             /* draw holodeck section grids */
737 >        int     fore
738 > )
739   {
740          glPushAttrib(GL_LIGHTING_BIT|GL_ENABLE_BIT);
741          glDisable(GL_LIGHTING);
# Line 712 | Line 751 | int    fore;
751   }
752  
753  
754 < static
755 < moveview(dx, dy, mov, orb)      /* move our view */
756 < int     dx, dy, mov, orb;
754 > static int
755 > moveview(       /* move our view */
756 >        int     dx,
757 >        int     dy,
758 >        int     mov,
759 >        int     orb
760 > )
761   {
762          VIEW    nv;
763          FVECT   odir, v1, wip;
764          double  d, d1;
722        register int    li;
765                                  /* start with old view */
766          nv = odev.v;
767                                  /* orient our motion */
# Line 767 | Line 809 | int    dx, dy, mov, orb;
809   }
810  
811  
812 < static
813 < getframe(ebut)                          /* get focus frame */
814 < XButtonPressedEvent     *ebut;
812 > static void
813 > getframe(                               /* get focus frame */
814 >        XButtonPressedEvent     *ebut
815 > )
816   {
817          int     startx = ebut->x, starty = ebut->y;
818          int     endx, endy;
# Line 777 | Line 820 | XButtonPressedEvent    *ebut;
820          XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent));
821          endx = levptr(XButtonReleasedEvent)->x;
822          endy = levptr(XButtonReleasedEvent)->y;
823 <        if (endx == startx | endy == starty) {
823 >        if ((endx == startx) | (endy == starty)) {
824                  XBell(ourdisplay, 0);
825                  return;
826          }
# Line 790 | Line 833 | XButtonPressedEvent    *ebut;
833   }
834  
835  
836 < static
837 < waitabit()                              /* pause a moment */
836 > static void
837 > waitabit(void)                          /* pause a moment */
838   {
839          struct timespec ts;
840          ts.tv_sec = 0;
# Line 800 | Line 843 | waitabit()                             /* pause a moment */
843   }
844  
845  
846 < static
847 < getmove(ebut)                           /* get view change */
848 < XButtonPressedEvent     *ebut;
846 > static void
847 > getmove(                                /* get view change */
848 >        XButtonPressedEvent     *ebut
849 > )
850   {
851          int     movdir = MOVDIR(ebut->button);
852          int     movorb = MOVORB(ebut->state);
# Line 857 | Line 901 | XButtonPressedEvent    *ebut;
901   }
902  
903  
904 < static
905 < setglpersp()                    /* set perspective view in GL */
904 > static void
905 > setglpersp(void)                        /* set perspective view in GL */
906   {
907          double  d, xmin, xmax, ymin, ymax;
908          GLfloat vec[4];
# Line 919 | Line 963 | setglpersp()                   /* set perspective view in GL */
963   }
964  
965  
966 < static
967 < setglortho()                    /* set up orthographic view for cone drawing */
966 > static void
967 > setglortho(void)                        /* set up orthographic view for cone drawing */
968   {
969          glDrawBuffer(GL_FRONT);         /* use single-buffer mode */
970                                          /* set view matrix */
# Line 936 | Line 980 | setglortho()                   /* set up orthographic view for cone dr
980   }
981  
982  
983 < static
984 < wipeclean()                     /* prepare for redraw */
983 > static void
984 > wipeclean(void)                 /* prepare for redraw */
985   {
986          glDrawBuffer(GL_BACK);          /* use double-buffer mode */
987          glReadBuffer(GL_BACK);
# Line 959 | Line 1003 | wipeclean()                    /* prepare for redraw */
1003   }
1004  
1005  
1006 < static
1007 < getkey(ekey)                            /* get input key */
1008 < register XKeyPressedEvent  *ekey;
1006 > static void
1007 > getkey(                         /* get input key */
1008 >        register XKeyPressedEvent  *ekey
1009 > )
1010   {
1011          Window  rootw, childw;
1012          int     rootx, rooty, wx, wy;
# Line 1042 | Line 1087 | register XKeyPressedEvent  *ekey;
1087   }
1088  
1089  
1090 < static
1091 < fixwindow(eexp)                         /* repair damage to window */
1092 < register XExposeEvent  *eexp;
1090 > static void
1091 > fixwindow(                              /* repair damage to window */
1092 >        register XExposeEvent  *eexp
1093 > )
1094   {
1095          int     xmin, ymin, xmax, ymax;
1096  
1097 <        if (odev.hres == 0 | odev.vres == 0) {  /* first exposure */
1097 >        if ((odev.hres == 0) | (odev.vres == 0)) {      /* first exposure */
1098                  resizewindow((XConfigureEvent *)eexp);
1099                  return;
1100          }
# Line 1087 | Line 1133 | register XExposeEvent  *eexp;
1133   }
1134  
1135  
1136 < static
1137 < resizewindow(ersz)                      /* resize window */
1138 < register XConfigureEvent  *ersz;
1136 > static void
1137 > resizewindow(                   /* resize window */
1138 >        register XConfigureEvent  *ersz
1139 > )
1140   {
1141          glViewport(0, 0, ersz->width, ersz->height);
1142  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines