--- ray/src/hd/rhd_x11.c 1998/01/06 13:07:57 3.24 +++ ray/src/hd/rhd_x11.c 1998/08/27 19:32:27 3.28 @@ -1,4 +1,4 @@ -/* Copyright (c) 1997 Silicon Graphics, Inc. */ +/* Copyright (c) 1998 Silicon Graphics, Inc. */ #ifndef lint static char SCCSid[] = "$SunId$ SGI"; @@ -265,6 +265,26 @@ VIEW *nv; } +dev_auxcom(cmd, args) /* process an auxiliary command */ +char *cmd, *args; +{ + sprintf(errmsg, "%s: unknown command", cmd); + error(COMMAND, errmsg); +} + + +VIEW * +dev_auxview(n, hvres) /* return nth auxiliary view */ +int n; +int hvres[2]; +{ + if (n) + return(NULL); + hvres[0] = odev.hres; hvres[1] = odev.vres; + return(&odev.v); +} + + int dev_input() /* get X11 input */ { @@ -273,8 +293,10 @@ dev_input() /* get X11 input */ do getevent(); - while (XQLength(ourdisplay) > 0); + while (XPending(ourdisplay) > 0); + odev.inpready = 0; + return(inpresflags); } @@ -302,7 +324,7 @@ dev_flush() /* flush output */ { qtUpdate(); rayqleft = RAYQLEN; - return(XPending(ourdisplay)); + return(odev.inpready = XPending(ourdisplay)); } @@ -442,11 +464,29 @@ ilclip(dp, wp) /* clip world coordinates to device * int dp[2][2]; FVECT wp[2]; { - static FVECT vmin = {0.,0.,0.}, vmax = {1.,1.,FHUGE}; - FVECT ip[2]; - /* not exactly right, but who cares? */ - viewloc(ip[0], &odev.v, wp[0]); - viewloc(ip[1], &odev.v, wp[1]); + static FVECT vmin = {0.,0.,0.}, vmax = {1.-FTINY,1.-FTINY,FHUGE}; + FVECT wpc[2], ip[2]; + double d, d0, d1; + /* check for points behind view */ + d = DOT(odev.v.vp, odev.v.vdir); + d0 = DOT(wp[0], odev.v.vdir) - d; + d1 = DOT(wp[1], odev.v.vdir) - d; + /* work on copy of world points */ + if (d0 <= d1) { + VCOPY(wpc[0], wp[0]); VCOPY(wpc[1], wp[1]); + } else { + d = d0; d0 = d1; d1 = d; + VCOPY(wpc[1], wp[0]); VCOPY(wpc[0], wp[1]); + } + if (d0 <= FTINY) { + if (d1 <= FTINY) return(0); + VSUB(wpc[0], wpc[0], wpc[1]); + d = .99*d1/(d1-d0); + VSUM(wpc[0], wpc[1], wpc[0], d); + } + /* get view coordinates and clip to window */ + viewloc(ip[0], &odev.v, wpc[0]); + viewloc(ip[1], &odev.v, wpc[1]); if (!clip(ip[0], ip[1], vmin, vmax)) return(0); dp[0][0] = ip[0][0]*odev.hres; @@ -477,8 +517,6 @@ draw_grids() /* draw holodeck section grids */ static BYTE gridrgb[3] = {0x0, 0xff, 0xff}; unsigned long pixel; - if (!mapped) - return; if (ncolors > 0) pixel = pixval[get_pixel(gridrgb, xnewcolr)]; else