28 |
|
#include "standard.h" |
29 |
|
#include "rhd_odraw.h" |
30 |
|
#include "rhdisp.h" |
31 |
+ |
#include "paths.h" |
32 |
|
#ifdef DOBJ |
33 |
|
#include "rhdobj.h" |
34 |
|
#endif |
82 |
|
|
83 |
|
struct driver odev; /* global device driver structure */ |
84 |
|
|
85 |
+ |
TMstruct *tmGlobal; /* global tone-mapping structure */ |
86 |
+ |
|
87 |
|
char odev_args[64]; /* command arguments */ |
88 |
|
|
89 |
|
static GLfloat *depthbuffer = NULL; /* depth buffer */ |
211 |
|
&myprims[BLU][CIEX],&myprims[BLU][CIEY], |
212 |
|
&myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) |
213 |
|
dpri = myprims; |
214 |
< |
if (tmInit(mytmflags(), dpri, gamval) == NULL) |
214 |
> |
tmGlobal = tmInit(mytmflags(), dpri, gamval); |
215 |
> |
if (tmGlobal == NULL) |
216 |
|
error(SYSTEM, "not enough memory in dev_open"); |
217 |
|
/* open window */ |
218 |
|
ourwinattr.background_pixel = ourblack; |
302 |
|
gwind = 0; |
303 |
|
XCloseDisplay(ourdisplay); |
304 |
|
ourdisplay = NULL; |
305 |
< |
tmDone(NULL); |
305 |
> |
tmDone(tmGlobal); |
306 |
|
odev.v.type = 0; |
307 |
|
odev.hres = odev.vres = 0; |
308 |
|
odev.ifd = -1; |
819 |
|
) |
820 |
|
{ |
821 |
|
int startx = ebut->x, starty = ebut->y; |
822 |
< |
int endx, endy; |
823 |
< |
|
822 |
> |
int endx, endy, midx, midy; |
823 |
> |
FVECT odir, v1; |
824 |
> |
double d, d1; |
825 |
> |
/* get mouse drag */ |
826 |
|
XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent)); |
827 |
|
endx = levptr(XButtonReleasedEvent)->x; |
828 |
|
endy = levptr(XButtonReleasedEvent)->y; |
829 |
< |
if ((endx == startx) | (endy == starty)) { |
830 |
< |
XBell(ourdisplay, 0); |
829 |
> |
midx = (startx + endx) >> 1; |
830 |
> |
midy = (starty + endy) >> 1; |
831 |
> |
/* set focus distance */ |
832 |
> |
if (viewray(v1, odir, &odev.v, |
833 |
> |
(midx+.5)/odev.hres, (midy+.5)/odev.vres) < -FTINY) |
834 |
|
return; |
835 |
< |
} |
835 |
> |
d = getdistance(midx, midy, odir); /* distance from front plane */ |
836 |
> |
#ifdef DOBJ |
837 |
> |
d1 = dobj_trace(NULL, v1, odir); |
838 |
> |
if (d1 < d) |
839 |
> |
d = d1; |
840 |
> |
#endif |
841 |
> |
if (d < .99*FHUGE) |
842 |
> |
odev.v.vdist = d + sqrt(dist2(v1, odev.v.vp)); |
843 |
> |
/* set frame for rendering */ |
844 |
> |
if ((endx == startx) | (endy == starty)) |
845 |
> |
return; |
846 |
|
if (endx < startx) {register int c = endx; endx = startx; startx = c;} |
847 |
|
if (endy < starty) {register int c = endy; endy = starty; starty = c;} |
848 |
|
sprintf(odev_args, "%.3f %.3f %.3f %.3f", |