--- ray/src/hd/rhd_ogl.c 2012/09/06 00:07:43 3.31 +++ ray/src/hd/rhd_ogl.c 2021/02/12 00:53:56 3.34 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rhd_ogl.c,v 3.31 2012/09/06 00:07:43 greg Exp $"; +static const char RCSid[] = "$Id: rhd_ogl.c,v 3.34 2021/02/12 00:53:56 greg Exp $"; #endif /* * OpenGL driver for holodeck display. @@ -49,10 +49,6 @@ static const char RCSid[] = "$Id: rhd_ogl.c,v 3.31 201 #define BORWIDTH 5 /* border width */ #endif -#ifndef FEQ -#define FEQ(a,b) ((a)-(b) <= FTINY && (a)-(b) >= -FTINY) -#endif - #define VWHEADLOCK 01 /* head position is locked flag */ #define VWPERSP 02 /* perspective view is set */ #define VWORTHO 04 /* orthographic view is set */ @@ -129,14 +125,14 @@ static void freedepth(void); static double getdistance(int dx, int dy, FVECT direc); static int mytmflags(void); static void getevent(void); -static void draw3dline(register FVECT wp[2]); +static void draw3dline(FVECT wp[2]); static void draw_grids(int fore); static int moveview(int dx, int dy, int mov, int orb); static void getframe(XButtonPressedEvent *ebut); static void getmove(XButtonPressedEvent *ebut); -static void getkey(register XKeyPressedEvent *ekey); -static void fixwindow(register XExposeEvent *eexp); -static void resizewindow(register XConfigureEvent *ersz); +static void getkey(XKeyPressedEvent *ekey); +static void fixwindow(XExposeEvent *eexp); +static void resizewindow(XConfigureEvent *ersz); static void waitabit(void); static void setglpersp(void); static void setglortho(void); @@ -153,7 +149,7 @@ extern int gmPortals; /* GL portal list id */ extern time_t time(); -extern void +void dev_open(id) /* initialize GLX driver */ char *id; { @@ -286,7 +282,7 @@ char *id; } -extern void +void dev_close(void) /* close our display and free resources */ { #ifdef DOBJ @@ -309,7 +305,7 @@ dev_close(void) /* close our display and free resour } -extern void +void dev_clear(void) /* clear our representation */ { viewflags |= VWCHANGE; /* pretend our view has changed */ @@ -319,9 +315,9 @@ dev_clear(void) /* clear our representation */ } -extern int +int dev_view( /* assign new driver view */ - register VIEW *nv + VIEW *nv ) { #ifdef STEREO @@ -337,8 +333,8 @@ dev_view( /* assign new driver view */ } if (nv != &odev.v) { /* resize window? */ - if (!FEQ(nv->horiz,odev.v.horiz) || - !FEQ(nv->vert,odev.v.vert)) { + if (!FABSEQ(nv->horiz,odev.v.horiz) || + !FABSEQ(nv->vert,odev.v.vert)) { int dw = DisplayWidth(ourdisplay,ourscreen); int dh = DisplayHeight(ourdisplay,ourscreen); @@ -376,7 +372,7 @@ dev_view( /* assign new driver view */ } -extern void +void dev_section( /* add octree for geometry rendering */ char *gfn, char *pfn @@ -401,7 +397,7 @@ dev_section( /* add octree for geometry rendering */ } -extern void +void dev_auxcom( /* process an auxiliary command */ char *cmd, char *args @@ -423,7 +419,7 @@ dev_auxcom( /* process an auxiliary command */ } -extern VIEW * +VIEW * dev_auxview( /* return nth auxiliary view */ int n, int hvres[2] @@ -440,7 +436,7 @@ dev_auxview( /* return nth auxiliary view */ } -extern int +int dev_input(void) /* get X11 input */ { inpresflags = 0; @@ -456,7 +452,7 @@ dev_input(void) /* get X11 input */ } -extern void +void dev_value( /* add a pixel value to our texture */ COLR c, FVECT d, @@ -475,7 +471,7 @@ dev_value( /* add a pixel value to our texture */ } -extern int +int dev_flush(void) /* flush output as appropriate */ { int ndrawn; @@ -527,7 +523,7 @@ checkglerr( /* check for GL or GLU error */ char *where ) { - register GLenum errcode; + GLenum errcode; while ((errcode = glGetError()) != GL_NO_ERROR) { sprintf(errmsg, "OpenGL error %s: %s", @@ -540,8 +536,8 @@ checkglerr( /* check for GL or GLU error */ static void xferdepth(void) /* load and clear depth buffer */ { - register GLfloat *dbp; - register GLubyte *pbuf; + GLfloat *dbp; + GLubyte *pbuf; if (depthbuffer == NULL) { /* allocate private depth buffer */ #ifdef STEREO @@ -677,7 +673,7 @@ static int mytmflags(void) /* figure out tone mapping flags */ { extern char *progname; - register char *cp, *tail; + char *cp, *tail; /* find basic name */ for (cp = tail = progname; *cp; cp++) if (*cp == '/') @@ -720,10 +716,17 @@ getevent(void) /* get next event */ getkey(levptr(XKeyPressedEvent)); break; case ButtonPress: - if (FRAMESTATE(levptr(XButtonPressedEvent)->state)) - getframe(levptr(XButtonPressedEvent)); + if (FRAMESTATE(levptr(XButtonPressedEvent)->state)) + getframe(levptr(XButtonPressedEvent)); else - getmove(levptr(XButtonPressedEvent)); + switch (levptr(XButtonPressedEvent)->button) { + case Button4: /* wheel up */ + case Button5: /* wheel down */ + break; + default: + getmove(levptr(XButtonPressedEvent)); + break; + } break; } } @@ -731,7 +734,7 @@ getevent(void) /* get next event */ static void draw3dline( /* draw 3d line in world coordinates */ - register FVECT wp[2] + FVECT wp[2] ) { glVertex3d(wp[0][0], wp[0][1], wp[0][2]); @@ -851,8 +854,8 @@ getframe( /* get focus frame */ /* set frame for rendering */ if ((endx == startx) | (endy == starty)) return; - if (endx < startx) {register int c = endx; endx = startx; startx = c;} - if (endy < starty) {register int c = endy; endy = starty; starty = c;} + if (endx < startx) {int c = endx; endx = startx; startx = c;} + if (endy < starty) {int c = endy; endy = starty; starty = c;} sprintf(odev_args, "%.3f %.3f %.3f %.3f", (startx+.5)/odev.hres, 1.-(endy+.5)/odev.vres, (endx+.5)/odev.hres, 1.-(starty+.5)/odev.vres); @@ -1032,7 +1035,7 @@ wipeclean(void) /* prepare for redraw */ static void getkey( /* get input key */ - register XKeyPressedEvent *ekey + XKeyPressedEvent *ekey ) { Window rootw, childw; @@ -1116,7 +1119,7 @@ getkey( /* get input key */ static void fixwindow( /* repair damage to window */ - register XExposeEvent *eexp + XExposeEvent *eexp ) { int xmin, ymin, xmax, ymax; @@ -1162,7 +1165,7 @@ fixwindow( /* repair damage to window */ static void resizewindow( /* resize window */ - register XConfigureEvent *ersz + XConfigureEvent *ersz ) { glViewport(0, 0, ersz->width, ersz->height);