19 |
|
#include "plocate.h" |
20 |
|
#include "rhdisp.h" |
21 |
|
#include "rhd_qtree.h" |
22 |
< |
#include "x11icon.h" |
22 |
> |
#include "x11icon.h" |
23 |
|
|
24 |
|
#ifndef RAYQLEN |
25 |
|
#define RAYQLEN 50000 /* max. rays to queue before flush */ |
54 |
|
|
55 |
|
struct driver odev; /* global device driver structure */ |
56 |
|
|
57 |
+ |
TMstruct *tmGlobal; /* global tone-mapping structure */ |
58 |
+ |
|
59 |
|
char odev_args[64]; /* command arguments */ |
60 |
|
|
61 |
|
static XEvent currentevent; /* current event */ |
82 |
|
static void xnewcolr(int ndx, int r, int g, int b); |
83 |
|
static int getpixels(void); |
84 |
|
static void freepixels(void); |
85 |
< |
static unsigned long true_pixel(register BYTE rgb[3]); |
85 |
> |
static unsigned long true_pixel(uby8 rgb[3]); |
86 |
|
static void getevent(void); |
87 |
|
static int ilclip(int dp[2][2], FVECT wp[2]); |
88 |
|
static void draw3dline(FVECT wp[2]); |
91 |
|
static void getframe(XButtonPressedEvent *ebut); |
92 |
|
static void waitabit(void); |
93 |
|
static void getmove(XButtonPressedEvent *ebut); |
94 |
< |
static void getkey(register XKeyPressedEvent *ekey); |
95 |
< |
static void fixwindow(register XExposeEvent *eexp); |
96 |
< |
static void resizewindow(register XConfigureEvent *ersz); |
94 |
> |
static void getkey(XKeyPressedEvent *ekey); |
95 |
> |
static void fixwindow(XExposeEvent *eexp); |
96 |
> |
static void resizewindow(XConfigureEvent *ersz); |
97 |
|
|
98 |
|
|
99 |
|
static int |
100 |
|
mytmflags(void) /* figure out tone mapping flags */ |
101 |
|
{ |
102 |
|
extern char *progname; |
103 |
< |
register char *cp, *tail; |
103 |
> |
char *cp, *tail; |
104 |
|
/* find basic name */ |
105 |
|
for (cp = tail = progname; *cp; cp++) |
106 |
|
if (*cp == '/') |
167 |
|
&myprims[BLU][CIEX],&myprims[BLU][CIEY], |
168 |
|
&myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) |
169 |
|
dpri = myprims; |
170 |
< |
if (tmInit(mytmflags(), dpri, gamval) == NULL) |
170 |
> |
tmGlobal = tmInit(mytmflags(), dpri, gamval); |
171 |
> |
if (tmGlobal == NULL) |
172 |
|
error(SYSTEM, "not enough memory in dev_open"); |
173 |
|
/* open window */ |
174 |
|
ourwinattr.background_pixel = ourblack; |
190 |
|
/* set window manager hints */ |
191 |
|
ourxwmhints.flags = InputHint|IconPixmapHint; |
192 |
|
ourxwmhints.input = True; |
193 |
< |
ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, |
194 |
< |
gwind, x11icon_bits, x11icon_width, x11icon_height); |
193 |
> |
ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, gwind, |
194 |
> |
(char *)x11icon_bits, x11icon_width, x11icon_height); |
195 |
|
XSetWMHints(ourdisplay, gwind, &ourxwmhints); |
196 |
|
oursizhints.min_width = MINWIDTH; |
197 |
|
oursizhints.min_height = MINHEIGHT; |
228 |
|
XCloseDisplay(ourdisplay); |
229 |
|
ourdisplay = NULL; |
230 |
|
qtFreeLeaves(); |
231 |
< |
tmDone(NULL); |
231 |
> |
tmDone(tmGlobal); |
232 |
|
odev.v.type = 0; |
233 |
|
odev.hres = odev.vres = 0; |
234 |
|
odev.ifd = -1; |
295 |
|
|
296 |
|
extern void |
297 |
|
dev_section( /* add octree for geometry rendering */ |
298 |
< |
char *ofn |
298 |
> |
char *gfn, |
299 |
> |
char *pfn |
300 |
|
) |
301 |
|
{ |
302 |
|
/* unimplemented */ |
345 |
|
|
346 |
|
extern void |
347 |
|
dev_paintr( /* fill a rectangle */ |
348 |
< |
BYTE rgb[3], |
348 |
> |
uby8 rgb[3], |
349 |
|
int xmin, |
350 |
|
int ymin, |
351 |
|
int xmax, |
399 |
|
getpixels(void) /* get the color map */ |
400 |
|
{ |
401 |
|
XColor thiscolor; |
402 |
< |
register int i, j; |
402 |
> |
int i, j; |
403 |
|
|
404 |
|
if (ncolors > 0) |
405 |
|
return(ncolors); |
464 |
|
|
465 |
|
static unsigned long |
466 |
|
true_pixel( /* return true pixel value for color */ |
467 |
< |
register BYTE rgb[3] |
467 |
> |
uby8 rgb[3] |
468 |
|
) |
469 |
|
{ |
470 |
< |
register unsigned long rval; |
470 |
> |
unsigned long rval; |
471 |
|
|
472 |
|
rval = ourvinfo.red_mask*rgb[RED]/255 & ourvinfo.red_mask; |
473 |
|
rval |= ourvinfo.green_mask*rgb[GRN]/255 & ourvinfo.green_mask; |
506 |
|
case ButtonPress: |
507 |
|
if (FRAMESTATE(levptr(XButtonPressedEvent)->state)) |
508 |
|
getframe(levptr(XButtonPressedEvent)); |
509 |
< |
else |
510 |
< |
getmove(levptr(XButtonPressedEvent)); |
509 |
> |
else |
510 |
> |
switch (levptr(XButtonPressedEvent)->button) { |
511 |
> |
case Button4: /* wheel up */ |
512 |
> |
case Button5: /* wheel down */ |
513 |
> |
break; |
514 |
> |
default: |
515 |
> |
getmove(levptr(XButtonPressedEvent)); |
516 |
> |
break; |
517 |
> |
} |
518 |
|
break; |
519 |
|
} |
520 |
|
} |
577 |
|
static void |
578 |
|
draw_grids(void) /* draw holodeck section grids */ |
579 |
|
{ |
580 |
< |
static BYTE gridrgb[3] = {0x0, 0xff, 0xff}; |
580 |
> |
static uby8 gridrgb[3] = {0x0, 0xff, 0xff}; |
581 |
|
unsigned long pixel; |
582 |
|
|
583 |
|
if (ncolors > 0) |
601 |
|
VIEW nv; |
602 |
|
FVECT odir, v1; |
603 |
|
double d; |
604 |
< |
register int li; |
604 |
> |
int li; |
605 |
|
/* start with old view */ |
606 |
|
nv = odev.v; |
607 |
|
/* change view direction */ |
619 |
|
VSUM(nv.vp, qtL.wp[li], odir, -1.); |
620 |
|
spinvector(nv.vdir, nv.vdir, nv.vup, d); |
621 |
|
} else if (orb) { /* orbit up/down */ |
622 |
< |
fcross(v1, odir, nv.vup); |
623 |
< |
if (normalize(v1) == 0.) |
622 |
> |
if (geodesic(odir, odir, nv.vup, |
623 |
> |
d=MOVDEG*PI/180.*orb, GEOD_RAD) == 0.0) |
624 |
|
return(0); |
614 |
– |
spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb); |
625 |
|
VSUM(nv.vp, qtL.wp[li], odir, -1.); |
626 |
< |
spinvector(nv.vdir, nv.vdir, v1, d); |
626 |
> |
geodesic(nv.vdir, nv.vdir, nv.vup, d, GEOD_RAD); |
627 |
|
} else if (mov) { /* move forward/backward */ |
628 |
|
d = MOVPCT/100. * mov; |
629 |
|
VSUM(nv.vp, nv.vp, odir, d); |
647 |
|
) |
648 |
|
{ |
649 |
|
int startx = ebut->x, starty = ebut->y; |
650 |
< |
int endx, endy; |
651 |
< |
|
650 |
> |
int endx, endy, midx, midy; |
651 |
> |
FVECT v1; |
652 |
> |
int li; |
653 |
> |
/* get mouse drag */ |
654 |
|
XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent)); |
655 |
|
endx = levptr(XButtonReleasedEvent)->x; |
656 |
|
endy = levptr(XButtonReleasedEvent)->y; |
657 |
< |
if ((endx == startx) | (endy == starty)) { |
658 |
< |
XBell(ourdisplay, 0); |
657 |
> |
midx = (startx + endx) >> 1; |
658 |
> |
midy = (starty + endy) >> 1; |
659 |
> |
/* set focus distance */ |
660 |
> |
if ((li = qtFindLeaf(midx, midy)) < 0) |
661 |
> |
return; /* not on window */ |
662 |
> |
VCOPY(v1, qtL.wp[li]); |
663 |
> |
odev.v.vdist = sqrt(dist2(odev.v.vp, v1)); |
664 |
> |
/* set frame for rendering */ |
665 |
> |
if ((endx == startx) | (endy == starty)) |
666 |
|
return; |
667 |
< |
} |
668 |
< |
if (endx < startx) {register int c = endx; endx = startx; startx = c;} |
650 |
< |
if (endy < starty) {register int c = endy; endy = starty; starty = c;} |
667 |
> |
if (endx < startx) {int c = endx; endx = startx; startx = c;} |
668 |
> |
if (endy < starty) {int c = endy; endy = starty; starty = c;} |
669 |
|
sprintf(odev_args, "%.3f %.3f %.3f %.3f", |
670 |
|
(startx+.5)/odev.hres, 1.-(endy+.5)/odev.vres, |
671 |
|
(endx+.5)/odev.hres, 1.-(starty+.5)/odev.vres); |
727 |
|
|
728 |
|
static void |
729 |
|
getkey( /* get input key */ |
730 |
< |
register XKeyPressedEvent *ekey |
730 |
> |
XKeyPressedEvent *ekey |
731 |
|
) |
732 |
|
{ |
733 |
|
Window rootw, childw; |
809 |
|
|
810 |
|
static void |
811 |
|
fixwindow( /* repair damage to window */ |
812 |
< |
register XExposeEvent *eexp |
812 |
> |
XExposeEvent *eexp |
813 |
|
) |
814 |
|
{ |
815 |
|
if (odev.hres == 0 || odev.vres == 0) { /* first exposure */ |
823 |
|
|
824 |
|
static void |
825 |
|
resizewindow( /* resize window */ |
826 |
< |
register XConfigureEvent *ersz |
826 |
> |
XConfigureEvent *ersz |
827 |
|
) |
828 |
|
{ |
829 |
|
if (ersz->width == odev.hres && ersz->height == odev.vres) |