6 |
|
* Based on rview driver. |
7 |
|
*/ |
8 |
|
|
9 |
< |
#include "standard.h" |
9 |
> |
#include <stdlib.h> |
10 |
> |
#include <stdio.h> |
11 |
|
#include <X11/Xlib.h> |
12 |
|
#include <X11/cursorfont.h> |
13 |
|
#include <X11/Xutil.h> |
14 |
|
#include <time.h> |
15 |
+ |
|
16 |
+ |
#include "platform.h" |
17 |
+ |
#include "rtmath.h" |
18 |
+ |
#include "rterror.h" |
19 |
+ |
#include "plocate.h" |
20 |
+ |
#include "rhdisp.h" |
21 |
|
#include "rhd_qtree.h" |
22 |
|
#include "x11icon.h" |
23 |
|
|
75 |
|
|
76 |
|
static int headlocked = 0; /* lock vertical motion */ |
77 |
|
|
71 |
– |
static int getpixels(), xnewcolr(), freepixels(), resizewindow(), getframe(), |
72 |
– |
getevent(), getkey(), moveview(), getmove(), fixwindow(); |
73 |
– |
static unsigned long true_pixel(); |
78 |
|
|
79 |
+ |
static int mytmflags(void); |
80 |
+ |
static void xnewcolr(int ndx, int r, int g, int b); |
81 |
+ |
static int getpixels(void); |
82 |
+ |
static void freepixels(void); |
83 |
+ |
static unsigned long true_pixel(register BYTE rgb[3]); |
84 |
+ |
static void getevent(void); |
85 |
+ |
static int ilclip(int dp[2][2], FVECT wp[2]); |
86 |
+ |
static void draw3dline(FVECT wp[2]); |
87 |
+ |
static void draw_grids(void); |
88 |
+ |
static int moveview(int dx, int dy, int mov, int orb); |
89 |
+ |
static void getframe(XButtonPressedEvent *ebut); |
90 |
+ |
static void waitabit(void); |
91 |
+ |
static void getmove(XButtonPressedEvent *ebut); |
92 |
+ |
static void getkey(register XKeyPressedEvent *ekey); |
93 |
+ |
static void fixwindow(register XExposeEvent *eexp); |
94 |
+ |
static void resizewindow(register XConfigureEvent *ersz); |
95 |
|
|
96 |
+ |
|
97 |
|
static int |
98 |
< |
mytmflags() /* figure out tone mapping flags */ |
98 |
> |
mytmflags(void) /* figure out tone mapping flags */ |
99 |
|
{ |
100 |
|
extern char *progname; |
101 |
|
register char *cp, *tail; |
110 |
|
if (cp-tail == 4 && !strncmp(tail, "x11h", 4)) |
111 |
|
return(TM_F_HUMAN|TM_F_NOSTDERR); |
112 |
|
error(USER, "illegal driver name"); |
113 |
+ |
return 0; /* pro forma return */ |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
< |
dev_open(id) /* initialize X11 driver */ |
118 |
< |
char *id; |
117 |
> |
extern void |
118 |
> |
dev_open( /* initialize X11 driver */ |
119 |
> |
char *id |
120 |
> |
) |
121 |
|
{ |
98 |
– |
extern char *getenv(); |
122 |
|
static RGBPRIMS myprims = STDPRIMS; |
123 |
|
char *ev; |
124 |
|
double gamval = GAMMA; |
199 |
|
DisplayWidth(ourdisplay, ourscreen); |
200 |
|
pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) / |
201 |
|
DisplayHeight(ourdisplay, ourscreen); |
202 |
< |
copystruct(&odev.v, &stdview); |
202 |
> |
odev.v = stdview; |
203 |
|
odev.v.type = VT_PER; |
204 |
|
/* map the window and get its size */ |
205 |
|
XMapWindow(ourdisplay, gwind); |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
< |
dev_close() /* close our display */ |
217 |
> |
extern void |
218 |
> |
dev_close(void) /* close our display */ |
219 |
|
{ |
220 |
|
freepixels(); |
221 |
|
XFreeGC(ourdisplay, ourgc); |
232 |
|
} |
233 |
|
|
234 |
|
|
235 |
< |
|
236 |
< |
dev_clear() /* clear our quadtree */ |
235 |
> |
extern void |
236 |
> |
dev_clear(void) /* clear our quadtree */ |
237 |
|
{ |
238 |
|
qtCompost(100); |
239 |
|
if (ncolors > 0) |
242 |
|
} |
243 |
|
|
244 |
|
|
245 |
< |
int |
246 |
< |
dev_view(nv) /* assign new driver view */ |
247 |
< |
VIEW *nv; |
245 |
> |
extern int |
246 |
> |
dev_view( /* assign new driver view */ |
247 |
> |
VIEW *nv |
248 |
> |
) |
249 |
|
{ |
250 |
|
if (nv->type == VT_PAR || /* check view legality */ |
251 |
|
nv->horiz > 160. || nv->vert > 160.) { |
283 |
|
XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); |
284 |
|
dev_input(); /* wait for resize event */ |
285 |
|
} |
286 |
< |
copystruct(&odev.v, nv); |
286 |
> |
odev.v = *nv; |
287 |
|
} |
288 |
|
qtReplant(); |
289 |
|
return(1); |
290 |
|
} |
291 |
|
|
292 |
|
|
293 |
< |
dev_section(ofn) /* add octree for geometry rendering */ |
294 |
< |
char *ofn; |
293 |
> |
extern void |
294 |
> |
dev_section( /* add octree for geometry rendering */ |
295 |
> |
char *ofn |
296 |
> |
) |
297 |
|
{ |
298 |
|
/* unimplemented */ |
299 |
|
} |
300 |
|
|
301 |
|
|
302 |
< |
dev_auxcom(cmd, args) /* process an auxiliary command */ |
303 |
< |
char *cmd, *args; |
302 |
> |
extern void |
303 |
> |
dev_auxcom( /* process an auxiliary command */ |
304 |
> |
char *cmd, |
305 |
> |
char *args |
306 |
> |
) |
307 |
|
{ |
308 |
|
sprintf(errmsg, "%s: unknown command", cmd); |
309 |
|
error(COMMAND, errmsg); |
310 |
|
} |
311 |
|
|
312 |
|
|
313 |
< |
VIEW * |
314 |
< |
dev_auxview(n, hvres) /* return nth auxiliary view */ |
315 |
< |
int n; |
316 |
< |
int hvres[2]; |
313 |
> |
extern VIEW * |
314 |
> |
dev_auxview( /* return nth auxiliary view */ |
315 |
> |
int n, |
316 |
> |
int hvres[2] |
317 |
> |
) |
318 |
|
{ |
319 |
|
if (n) |
320 |
|
return(NULL); |
323 |
|
} |
324 |
|
|
325 |
|
|
326 |
< |
int |
327 |
< |
dev_input() /* get X11 input */ |
326 |
> |
extern int |
327 |
> |
dev_input(void) /* get X11 input */ |
328 |
|
{ |
329 |
|
inpresflags = 0; |
330 |
|
|
339 |
|
} |
340 |
|
|
341 |
|
|
342 |
< |
dev_paintr(rgb, xmin, ymin, xmax, ymax) /* fill a rectangle */ |
343 |
< |
BYTE rgb[3]; |
344 |
< |
int xmin, ymin, xmax, ymax; |
342 |
> |
extern void |
343 |
> |
dev_paintr( /* fill a rectangle */ |
344 |
> |
BYTE rgb[3], |
345 |
> |
int xmin, |
346 |
> |
int ymin, |
347 |
> |
int xmax, |
348 |
> |
int ymax |
349 |
> |
) |
350 |
|
{ |
351 |
|
unsigned long pixel; |
352 |
|
|
362 |
|
} |
363 |
|
|
364 |
|
|
365 |
< |
int |
366 |
< |
dev_flush() /* flush output */ |
365 |
> |
extern int |
366 |
> |
dev_flush(void) /* flush output */ |
367 |
|
{ |
368 |
|
qtUpdate(); |
369 |
|
rayqleft = RAYQLEN; |
371 |
|
} |
372 |
|
|
373 |
|
|
374 |
< |
static |
375 |
< |
xnewcolr(ndx, r, g, b) /* enter a color into hardware table */ |
376 |
< |
int ndx; |
377 |
< |
int r, g, b; |
374 |
> |
static void |
375 |
> |
xnewcolr( /* enter a color into hardware table */ |
376 |
> |
int ndx, |
377 |
> |
int r, |
378 |
> |
int g, |
379 |
> |
int b |
380 |
> |
) |
381 |
|
{ |
382 |
|
XColor xcolor; |
383 |
|
|
392 |
|
|
393 |
|
|
394 |
|
static int |
395 |
< |
getpixels() /* get the color map */ |
395 |
> |
getpixels(void) /* get the color map */ |
396 |
|
{ |
397 |
|
XColor thiscolor; |
398 |
|
register int i, j; |
443 |
|
} |
444 |
|
|
445 |
|
|
446 |
< |
static |
447 |
< |
freepixels() /* free our pixels */ |
446 |
> |
static void |
447 |
> |
freepixels(void) /* free our pixels */ |
448 |
|
{ |
449 |
|
if (ncolors == 0) |
450 |
|
return; |
459 |
|
|
460 |
|
|
461 |
|
static unsigned long |
462 |
< |
true_pixel(rgb) /* return true pixel value for color */ |
463 |
< |
register BYTE rgb[3]; |
462 |
> |
true_pixel( /* return true pixel value for color */ |
463 |
> |
register BYTE rgb[3] |
464 |
> |
) |
465 |
|
{ |
466 |
|
register unsigned long rval; |
467 |
|
|
472 |
|
} |
473 |
|
|
474 |
|
|
475 |
< |
static |
476 |
< |
getevent() /* get next event */ |
475 |
> |
static void |
476 |
> |
getevent(void) /* get next event */ |
477 |
|
{ |
478 |
|
XNextEvent(ourdisplay, levptr(XEvent)); |
479 |
|
switch (levptr(XEvent)->type) { |
509 |
|
} |
510 |
|
|
511 |
|
|
512 |
< |
static |
513 |
< |
ilclip(dp, wp) /* clip world coordinates to device */ |
514 |
< |
int dp[2][2]; |
515 |
< |
FVECT wp[2]; |
512 |
> |
static int |
513 |
> |
ilclip( /* clip world coordinates to device */ |
514 |
> |
int dp[2][2], |
515 |
> |
FVECT wp[2] |
516 |
> |
) |
517 |
|
{ |
518 |
|
static FVECT vmin = {0.,0.,0.}, vmax = {1.-FTINY,1.-FTINY,FHUGE}; |
519 |
|
FVECT wpc[2], ip[2]; |
548 |
|
} |
549 |
|
|
550 |
|
|
551 |
< |
static |
552 |
< |
draw3dline(wp) /* draw 3d line in world coordinates */ |
553 |
< |
FVECT wp[2]; |
551 |
> |
static void |
552 |
> |
draw3dline( /* draw 3d line in world coordinates */ |
553 |
> |
FVECT wp[2] |
554 |
> |
) |
555 |
|
{ |
556 |
|
int dp[2][2]; |
557 |
|
|
563 |
|
} |
564 |
|
|
565 |
|
|
566 |
< |
static |
567 |
< |
draw_grids() /* draw holodeck section grids */ |
566 |
> |
static void |
567 |
> |
draw_grids(void) /* draw holodeck section grids */ |
568 |
|
{ |
569 |
|
static BYTE gridrgb[3] = {0x0, 0xff, 0xff}; |
570 |
|
unsigned long pixel; |
579 |
|
} |
580 |
|
|
581 |
|
|
582 |
< |
static |
583 |
< |
moveview(dx, dy, mov, orb) /* move our view */ |
584 |
< |
int dx, dy, mov, orb; |
582 |
> |
static int |
583 |
> |
moveview( /* move our view */ |
584 |
> |
int dx, |
585 |
> |
int dy, |
586 |
> |
int mov, |
587 |
> |
int orb |
588 |
> |
) |
589 |
|
{ |
590 |
|
VIEW nv; |
591 |
|
FVECT odir, v1; |
592 |
|
double d; |
593 |
|
register int li; |
594 |
|
/* start with old view */ |
595 |
< |
copystruct(&nv, &odev.v); |
595 |
> |
nv = odev.v; |
596 |
|
/* change view direction */ |
597 |
|
if (mov | orb) { |
598 |
|
if ((li = qtFindLeaf(dx, dy)) < 0) |
631 |
|
} |
632 |
|
|
633 |
|
|
634 |
< |
static |
635 |
< |
getframe(ebut) /* get focus frame */ |
636 |
< |
XButtonPressedEvent *ebut; |
634 |
> |
static void |
635 |
> |
getframe( /* get focus frame */ |
636 |
> |
XButtonPressedEvent *ebut |
637 |
> |
) |
638 |
|
{ |
639 |
|
int startx = ebut->x, starty = ebut->y; |
640 |
|
int endx, endy; |
642 |
|
XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent)); |
643 |
|
endx = levptr(XButtonReleasedEvent)->x; |
644 |
|
endy = levptr(XButtonReleasedEvent)->y; |
645 |
< |
if (endx == startx | endy == starty) { |
645 |
> |
if ((endx == startx) | (endy == starty)) { |
646 |
|
XBell(ourdisplay, 0); |
647 |
|
return; |
648 |
|
} |
655 |
|
} |
656 |
|
|
657 |
|
|
658 |
< |
static |
659 |
< |
waitabit() /* pause a moment */ |
658 |
> |
static void |
659 |
> |
waitabit(void) /* pause a moment */ |
660 |
|
{ |
661 |
|
struct timespec ts; |
662 |
|
ts.tv_sec = 0; |
663 |
< |
ts.tv_nsec = 5000000; |
663 |
> |
ts.tv_nsec = 100000000; |
664 |
|
nanosleep(&ts, NULL); |
665 |
|
} |
666 |
|
|
667 |
|
|
668 |
< |
static |
669 |
< |
getmove(ebut) /* get view change */ |
670 |
< |
XButtonPressedEvent *ebut; |
668 |
> |
static void |
669 |
> |
getmove( /* get view change */ |
670 |
> |
XButtonPressedEvent *ebut |
671 |
> |
) |
672 |
|
{ |
673 |
|
int movdir = MOVDIR(ebut->button); |
674 |
|
int movorb = MOVORB(ebut->state); |
707 |
|
} |
708 |
|
|
709 |
|
|
710 |
< |
static |
711 |
< |
getkey(ekey) /* get input key */ |
712 |
< |
register XKeyPressedEvent *ekey; |
710 |
> |
static void |
711 |
> |
getkey( /* get input key */ |
712 |
> |
register XKeyPressedEvent *ekey |
713 |
> |
) |
714 |
|
{ |
715 |
|
Window rootw, childw; |
716 |
|
int rootx, rooty, wx, wy; |
789 |
|
} |
790 |
|
|
791 |
|
|
792 |
< |
static |
793 |
< |
fixwindow(eexp) /* repair damage to window */ |
794 |
< |
register XExposeEvent *eexp; |
792 |
> |
static void |
793 |
> |
fixwindow( /* repair damage to window */ |
794 |
> |
register XExposeEvent *eexp |
795 |
> |
) |
796 |
|
{ |
797 |
|
if (odev.hres == 0 || odev.vres == 0) { /* first exposure */ |
798 |
|
odev.hres = eexp->width; |
803 |
|
} |
804 |
|
|
805 |
|
|
806 |
< |
static |
807 |
< |
resizewindow(ersz) /* resize window */ |
808 |
< |
register XConfigureEvent *ersz; |
806 |
> |
static void |
807 |
> |
resizewindow( /* resize window */ |
808 |
> |
register XConfigureEvent *ersz |
809 |
> |
) |
810 |
|
{ |
811 |
|
if (ersz->width == odev.hres && ersz->height == odev.vres) |
812 |
|
return; |