--- ray/src/hd/rhd_ogl.c 2004/02/12 18:55:50 3.25 +++ ray/src/hd/rhd_ogl.c 2006/05/23 13:01:07 3.29 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rhd_ogl.c,v 3.25 2004/02/12 18:55:50 greg Exp $"; +static const char RCSid[] = "$Id: rhd_ogl.c,v 3.29 2006/05/23 13:01:07 greg Exp $"; #endif /* * OpenGL driver for holodeck display. @@ -82,6 +82,8 @@ static const char RCSid[] = "$Id: rhd_ogl.c,v 3.25 200 struct driver odev; /* global device driver structure */ +TMstruct *tmGlobal; /* global tone-mapping structure */ + char odev_args[64]; /* command arguments */ static GLfloat *depthbuffer = NULL; /* depth buffer */ @@ -209,7 +211,8 @@ char *id; &myprims[BLU][CIEX],&myprims[BLU][CIEY], &myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) dpri = myprims; - if (tmInit(mytmflags(), dpri, gamval) == NULL) + tmGlobal = tmInit(mytmflags(), dpri, gamval); + if (tmGlobal == NULL) error(SYSTEM, "not enough memory in dev_open"); /* open window */ ourwinattr.background_pixel = ourblack; @@ -232,8 +235,8 @@ char *id; /* set window manager hints */ ourxwmhints.flags = InputHint|IconPixmapHint; ourxwmhints.input = True; - ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, - gwind, x11icon_bits, x11icon_width, x11icon_height); + ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, gwind, + (char *)x11icon_bits, x11icon_width, x11icon_height); XSetWMHints(ourdisplay, gwind, &ourxwmhints); oursizhints.min_width = MINWIDTH; #ifdef STEREO @@ -299,7 +302,7 @@ dev_close(void) /* close our display and free resour gwind = 0; XCloseDisplay(ourdisplay); ourdisplay = NULL; - tmDone(NULL); + tmDone(tmGlobal); odev.v.type = 0; odev.hres = odev.vres = 0; odev.ifd = -1; @@ -321,6 +324,9 @@ dev_view( /* assign new driver view */ register VIEW *nv ) { +#ifdef STEREO + double d; +#endif if (nv->type != VT_PER || /* check view legality */ nv->horiz > 160. || nv->vert > 160.) { error(COMMAND, "illegal view type/angle"); @@ -816,15 +822,30 @@ getframe( /* get focus frame */ ) { int startx = ebut->x, starty = ebut->y; - int endx, endy; - + int endx, endy, midx, midy; + FVECT odir, v1; + double d, d1; + /* get mouse drag */ XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent)); endx = levptr(XButtonReleasedEvent)->x; endy = levptr(XButtonReleasedEvent)->y; - if ((endx == startx) | (endy == starty)) { - XBell(ourdisplay, 0); + midx = (startx + endx) >> 1; + midy = (starty + endy) >> 1; + /* set focus distance */ + if (viewray(v1, odir, &odev.v, + (midx+.5)/odev.hres, (midy+.5)/odev.vres) < -FTINY) return; - } + d = getdistance(midx, midy, odir); /* distance from front plane */ +#ifdef DOBJ + d1 = dobj_trace(NULL, v1, odir); + if (d1 < d) + d = d1; +#endif + if (d < .99*FHUGE) + odev.v.vdist = d + sqrt(dist2(v1, odev.v.vp)); + /* 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;} sprintf(odev_args, "%.3f %.3f %.3f %.3f",