1 |
– |
/* Copyright (c) 1999 Silicon Graphics, Inc. */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ SGI"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* OpenGL driver for holodeck display. |
6 |
|
* Based on GLX driver using T-mesh. |
17 |
|
#endif |
18 |
|
#endif |
19 |
|
|
23 |
– |
#include "standard.h" |
20 |
|
|
21 |
+ |
#include <time.h> |
22 |
|
#include <GL/glx.h> |
23 |
|
#include <GL/glu.h> |
24 |
|
#ifdef STEREO |
25 |
|
#include <X11/extensions/SGIStereo.h> |
26 |
|
#endif |
27 |
|
|
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 |
49 |
|
#define BORWIDTH 5 /* border width */ |
50 |
|
#endif |
51 |
|
|
52 |
– |
#ifndef FEQ |
53 |
– |
#define FEQ(a,b) ((a)-(b) <= FTINY && (a)-(b) >= -FTINY) |
54 |
– |
#endif |
55 |
– |
|
52 |
|
#define VWHEADLOCK 01 /* head position is locked flag */ |
53 |
|
#define VWPERSP 02 /* perspective view is set */ |
54 |
|
#define VWORTHO 04 /* orthographic view is set */ |
78 |
|
|
79 |
|
struct driver odev; /* global device driver structure */ |
80 |
|
|
81 |
+ |
TMstruct *tmGlobal; /* global tone-mapping structure */ |
82 |
+ |
|
83 |
|
char odev_args[64]; /* command arguments */ |
84 |
|
|
85 |
|
static GLfloat *depthbuffer = NULL; /* depth buffer */ |
112 |
|
|
113 |
|
static int viewflags; /* what's happening with view */ |
114 |
|
|
115 |
+ |
/* |
116 |
|
static int resizewindow(), getevent(), getkey(), moveview(), wipeclean(), |
117 |
|
xferdepth(), freedepth(), setglortho(), |
118 |
|
setglpersp(), getframe(), getmove(), fixwindow(), mytmflags(); |
119 |
|
|
120 |
|
static double getdistance(); |
121 |
+ |
*/ |
122 |
+ |
static void checkglerr(char *where); |
123 |
+ |
static void xferdepth(void); |
124 |
+ |
static void freedepth(void); |
125 |
+ |
static double getdistance(int dx, int dy, FVECT direc); |
126 |
+ |
static int mytmflags(void); |
127 |
+ |
static void getevent(void); |
128 |
+ |
static void draw3dline(FVECT wp[2]); |
129 |
+ |
static void draw_grids(int fore); |
130 |
+ |
static int moveview(int dx, int dy, int mov, int orb); |
131 |
+ |
static void getframe(XButtonPressedEvent *ebut); |
132 |
+ |
static void getmove(XButtonPressedEvent *ebut); |
133 |
+ |
static void getkey(XKeyPressedEvent *ekey); |
134 |
+ |
static void fixwindow(XExposeEvent *eexp); |
135 |
+ |
static void resizewindow(XConfigureEvent *ersz); |
136 |
+ |
static void waitabit(void); |
137 |
+ |
static void setglpersp(void); |
138 |
+ |
static void setglortho(void); |
139 |
+ |
static void wipeclean(void); |
140 |
|
|
141 |
+ |
|
142 |
|
#ifdef STEREO |
143 |
< |
static int pushright(), popright(); |
143 |
> |
static void pushright(void); |
144 |
> |
static void popright(void); |
145 |
|
#endif |
146 |
|
|
147 |
|
extern int gmPortals; /* GL portal list id */ |
149 |
|
extern time_t time(); |
150 |
|
|
151 |
|
|
152 |
+ |
void |
153 |
|
dev_open(id) /* initialize GLX driver */ |
154 |
|
char *id; |
155 |
|
{ |
207 |
|
&myprims[BLU][CIEX],&myprims[BLU][CIEY], |
208 |
|
&myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) |
209 |
|
dpri = myprims; |
210 |
< |
if (tmInit(mytmflags(), dpri, gamval) == NULL) |
210 |
> |
tmGlobal = tmInit(mytmflags(), dpri, gamval); |
211 |
> |
if (tmGlobal == NULL) |
212 |
|
error(SYSTEM, "not enough memory in dev_open"); |
213 |
|
/* open window */ |
214 |
|
ourwinattr.background_pixel = ourblack; |
231 |
|
/* set window manager hints */ |
232 |
|
ourxwmhints.flags = InputHint|IconPixmapHint; |
233 |
|
ourxwmhints.input = True; |
234 |
< |
ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, |
235 |
< |
gwind, x11icon_bits, x11icon_width, x11icon_height); |
234 |
> |
ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay, gwind, |
235 |
> |
(char *)x11icon_bits, x11icon_width, x11icon_height); |
236 |
|
XSetWMHints(ourdisplay, gwind, &ourxwmhints); |
237 |
|
oursizhints.min_width = MINWIDTH; |
238 |
|
#ifdef STEREO |
267 |
|
setstereobuf(STEREO_BUFFER_LEFT); |
268 |
|
#endif |
269 |
|
checkglerr("setting rendering parameters"); |
270 |
< |
copystruct(&odev.v, &stdview); |
270 |
> |
odev.v = stdview; |
271 |
|
odev.v.type = VT_PER; |
272 |
|
viewflags = VWSTEADY; /* view starts static */ |
273 |
|
/* map the window */ |
282 |
|
} |
283 |
|
|
284 |
|
|
285 |
< |
dev_close() /* close our display and free resources */ |
285 |
> |
void |
286 |
> |
dev_close(void) /* close our display and free resources */ |
287 |
|
{ |
288 |
|
#ifdef DOBJ |
289 |
|
dobj_cleanup(); |
298 |
|
gwind = 0; |
299 |
|
XCloseDisplay(ourdisplay); |
300 |
|
ourdisplay = NULL; |
301 |
< |
tmDone(NULL); |
301 |
> |
tmDone(tmGlobal); |
302 |
|
odev.v.type = 0; |
303 |
|
odev.hres = odev.vres = 0; |
304 |
|
odev.ifd = -1; |
305 |
|
} |
306 |
|
|
307 |
|
|
308 |
< |
dev_clear() /* clear our representation */ |
308 |
> |
void |
309 |
> |
dev_clear(void) /* clear our representation */ |
310 |
|
{ |
311 |
|
viewflags |= VWCHANGE; /* pretend our view has changed */ |
312 |
|
wipeclean(); /* clean off display and samples */ |
316 |
|
|
317 |
|
|
318 |
|
int |
319 |
< |
dev_view(nv) /* assign new driver view */ |
320 |
< |
register VIEW *nv; |
319 |
> |
dev_view( /* assign new driver view */ |
320 |
> |
VIEW *nv |
321 |
> |
) |
322 |
|
{ |
323 |
+ |
#ifdef STEREO |
324 |
|
double d; |
325 |
< |
|
325 |
> |
#endif |
326 |
|
if (nv->type != VT_PER || /* check view legality */ |
327 |
|
nv->horiz > 160. || nv->vert > 160.) { |
328 |
|
error(COMMAND, "illegal view type/angle"); |
333 |
|
} |
334 |
|
if (nv != &odev.v) { |
335 |
|
/* resize window? */ |
336 |
< |
if (!FEQ(nv->horiz,odev.v.horiz) || |
337 |
< |
!FEQ(nv->vert,odev.v.vert)) { |
336 |
> |
if (!FABSEQ(nv->horiz,odev.v.horiz) || |
337 |
> |
!FABSEQ(nv->vert,odev.v.vert)) { |
338 |
|
int dw = DisplayWidth(ourdisplay,ourscreen); |
339 |
|
int dh = DisplayHeight(ourdisplay,ourscreen); |
340 |
|
|
358 |
|
XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); |
359 |
|
dev_input(); /* get resize event */ |
360 |
|
} |
361 |
< |
copystruct(&odev.v, nv); /* setview() already called */ |
361 |
> |
odev.v = *nv; /* setview() already called */ |
362 |
|
viewflags |= VWCHANGE; |
363 |
|
} |
364 |
|
#ifdef STEREO |
365 |
< |
copystruct(&vwright, nv); |
365 |
> |
vwright = *nv; |
366 |
|
d = eyesepdist / sqrt(nv->hn2); |
367 |
|
VSUM(vwright.vp, nv->vp, nv->hvec, d); |
368 |
|
/* setview(&vwright); -- Unnecessary */ |
372 |
|
} |
373 |
|
|
374 |
|
|
375 |
< |
dev_section(gfn, pfn) /* add octree for geometry rendering */ |
376 |
< |
char *gfn, *pfn; |
375 |
> |
void |
376 |
> |
dev_section( /* add octree for geometry rendering */ |
377 |
> |
char *gfn, |
378 |
> |
char *pfn |
379 |
> |
) |
380 |
|
{ |
352 |
– |
extern char *index(); |
353 |
– |
char *cp; |
354 |
– |
|
381 |
|
if (gfn == NULL) { |
382 |
|
gmEndGeom(); |
383 |
|
gmEndPortal(); |
397 |
|
} |
398 |
|
|
399 |
|
|
400 |
< |
dev_auxcom(cmd, args) /* process an auxiliary command */ |
401 |
< |
char *cmd, *args; |
400 |
> |
void |
401 |
> |
dev_auxcom( /* process an auxiliary command */ |
402 |
> |
char *cmd, |
403 |
> |
char *args |
404 |
> |
) |
405 |
|
{ |
406 |
|
#ifdef DOBJ |
407 |
|
int vischange; |
420 |
|
|
421 |
|
|
422 |
|
VIEW * |
423 |
< |
dev_auxview(n, hvres) /* return nth auxiliary view */ |
424 |
< |
int n; |
425 |
< |
int hvres[2]; |
423 |
> |
dev_auxview( /* return nth auxiliary view */ |
424 |
> |
int n, |
425 |
> |
int hvres[2] |
426 |
> |
) |
427 |
|
{ |
428 |
|
hvres[0] = odev.hres; hvres[1] = odev.vres; |
429 |
|
if (n == 0) |
437 |
|
|
438 |
|
|
439 |
|
int |
440 |
< |
dev_input() /* get X11 input */ |
440 |
> |
dev_input(void) /* get X11 input */ |
441 |
|
{ |
442 |
|
inpresflags = 0; |
443 |
|
|
452 |
|
} |
453 |
|
|
454 |
|
|
455 |
< |
dev_value(c, d, p) /* add a pixel value to our texture */ |
456 |
< |
COLR c; |
457 |
< |
FVECT d, p; |
455 |
> |
void |
456 |
> |
dev_value( /* add a pixel value to our texture */ |
457 |
> |
COLR c, |
458 |
> |
FVECT d, |
459 |
> |
FVECT p |
460 |
> |
) |
461 |
|
{ |
462 |
|
#ifdef DOBJ |
463 |
|
if (dobj_lightsamp != NULL) { /* in light source sampling */ |
472 |
|
|
473 |
|
|
474 |
|
int |
475 |
< |
dev_flush() /* flush output as appropriate */ |
475 |
> |
dev_flush(void) /* flush output as appropriate */ |
476 |
|
{ |
477 |
|
int ndrawn; |
478 |
|
|
518 |
|
} |
519 |
|
|
520 |
|
|
521 |
< |
checkglerr(where) /* check for GL or GLU error */ |
522 |
< |
char *where; |
521 |
> |
static void |
522 |
> |
checkglerr( /* check for GL or GLU error */ |
523 |
> |
char *where |
524 |
> |
) |
525 |
|
{ |
526 |
< |
register GLenum errcode; |
526 |
> |
GLenum errcode; |
527 |
|
|
528 |
|
while ((errcode = glGetError()) != GL_NO_ERROR) { |
529 |
|
sprintf(errmsg, "OpenGL error %s: %s", |
533 |
|
} |
534 |
|
|
535 |
|
|
536 |
< |
static |
537 |
< |
xferdepth() /* load and clear depth buffer */ |
536 |
> |
static void |
537 |
> |
xferdepth(void) /* load and clear depth buffer */ |
538 |
|
{ |
539 |
< |
register GLfloat *dbp; |
540 |
< |
register GLubyte *pbuf; |
539 |
> |
GLfloat *dbp; |
540 |
> |
GLubyte *pbuf; |
541 |
|
|
542 |
|
if (depthbuffer == NULL) { /* allocate private depth buffer */ |
543 |
|
#ifdef STEREO |
592 |
|
glClear(GL_DEPTH_BUFFER_BIT); /* clear system depth buffer */ |
593 |
|
odDepthMap(0, depthbuffer); /* transfer depth data */ |
594 |
|
if (pbuf != NULL) |
595 |
< |
free((char *)pbuf); /* free our portal buffer */ |
595 |
> |
free((void *)pbuf); /* free our portal buffer */ |
596 |
|
} |
597 |
|
|
598 |
|
|
599 |
< |
static |
600 |
< |
freedepth() /* free recorded depth buffer */ |
599 |
> |
static void |
600 |
> |
freedepth(void) /* free recorded depth buffer */ |
601 |
|
{ |
602 |
|
if (depthbuffer == NULL) |
603 |
|
return; |
604 |
|
#ifdef STEREO |
605 |
|
odDepthMap(1, NULL); |
606 |
< |
free((char *)depthright); |
606 |
> |
free((void *)depthright); |
607 |
|
depthright = NULL; |
608 |
|
#endif |
609 |
|
odDepthMap(0, NULL); |
610 |
< |
free((char *)depthbuffer); |
610 |
> |
free((void *)depthbuffer); |
611 |
|
depthbuffer = NULL; |
612 |
|
} |
613 |
|
|
614 |
|
|
615 |
|
static double |
616 |
< |
getdistance(dx, dy, direc) /* distance from fore plane along view ray */ |
617 |
< |
int dx, dy; |
618 |
< |
FVECT direc; |
616 |
> |
getdistance( /* distance from fore plane along view ray */ |
617 |
> |
int dx, |
618 |
> |
int dy, |
619 |
> |
FVECT direc |
620 |
> |
) |
621 |
|
{ |
622 |
|
GLfloat gldepth; |
623 |
|
double dist; |
624 |
|
|
625 |
< |
if (dx<0 | dx>=odev.hres | dy<0 | dy>=odev.vres) |
625 |
> |
if ((dx<0) | (dx>=odev.hres) | (dy<0) | (dy>=odev.vres)) |
626 |
|
return(FHUGE); |
627 |
|
if (depthbuffer != NULL) |
628 |
|
dist = depthbuffer[dy*odev.hres + dx]; |
629 |
|
else { |
630 |
|
glReadPixels(dx,dy, 1,1, GL_DEPTH_COMPONENT, |
631 |
|
GL_FLOAT, &gldepth); |
632 |
+ |
if (gldepth <= FTINY) |
633 |
+ |
return (FHUGE); /* call failed */ |
634 |
|
dist = mapdepth(gldepth); |
635 |
|
} |
636 |
|
if (dist >= .99*FHUGE) |
640 |
|
|
641 |
|
|
642 |
|
#ifdef STEREO |
643 |
< |
static |
644 |
< |
pushright() /* push on right view & buffer */ |
643 |
> |
static void |
644 |
> |
pushright(void) /* push on right view & buffer */ |
645 |
|
{ |
646 |
|
double d; |
647 |
|
|
657 |
|
} |
658 |
|
|
659 |
|
|
660 |
< |
static |
661 |
< |
popright() /* pop off right view & buffer */ |
660 |
> |
static void |
661 |
> |
popright(void) /* pop off right view & buffer */ |
662 |
|
{ |
663 |
|
if (viewflags & VWPERSP) { |
664 |
|
glMatrixMode(GL_MODELVIEW); |
670 |
|
|
671 |
|
|
672 |
|
static int |
673 |
< |
mytmflags() /* figure out tone mapping flags */ |
673 |
> |
mytmflags(void) /* figure out tone mapping flags */ |
674 |
|
{ |
675 |
|
extern char *progname; |
676 |
< |
register char *cp, *tail; |
676 |
> |
char *cp, *tail; |
677 |
|
/* find basic name */ |
678 |
|
for (cp = tail = progname; *cp; cp++) |
679 |
|
if (*cp == '/') |
694 |
|
} |
695 |
|
|
696 |
|
|
697 |
< |
static |
698 |
< |
getevent() /* get next event */ |
697 |
> |
static void |
698 |
> |
getevent(void) /* get next event */ |
699 |
|
{ |
700 |
|
XNextEvent(ourdisplay, levptr(XEvent)); |
701 |
|
switch (levptr(XEvent)->type) { |
716 |
|
getkey(levptr(XKeyPressedEvent)); |
717 |
|
break; |
718 |
|
case ButtonPress: |
719 |
< |
if (FRAMESTATE(levptr(XButtonPressedEvent)->state)) |
720 |
< |
getframe(levptr(XButtonPressedEvent)); |
719 |
> |
if (FRAMESTATE(levptr(XButtonPressedEvent)->state)) |
720 |
> |
getframe(levptr(XButtonPressedEvent)); |
721 |
|
else |
722 |
< |
getmove(levptr(XButtonPressedEvent)); |
722 |
> |
switch (levptr(XButtonPressedEvent)->button) { |
723 |
> |
case Button4: /* wheel up */ |
724 |
> |
case Button5: /* wheel down */ |
725 |
> |
break; |
726 |
> |
default: |
727 |
> |
getmove(levptr(XButtonPressedEvent)); |
728 |
> |
break; |
729 |
> |
} |
730 |
|
break; |
731 |
|
} |
732 |
|
} |
733 |
|
|
734 |
|
|
735 |
< |
static |
736 |
< |
draw3dline(wp) /* draw 3d line in world coordinates */ |
737 |
< |
register FVECT wp[2]; |
735 |
> |
static void |
736 |
> |
draw3dline( /* draw 3d line in world coordinates */ |
737 |
> |
FVECT wp[2] |
738 |
> |
) |
739 |
|
{ |
740 |
|
glVertex3d(wp[0][0], wp[0][1], wp[0][2]); |
741 |
|
glVertex3d(wp[1][0], wp[1][1], wp[1][2]); |
742 |
|
} |
743 |
|
|
744 |
|
|
745 |
< |
static |
746 |
< |
draw_grids(fore) /* draw holodeck section grids */ |
747 |
< |
int fore; |
745 |
> |
static void |
746 |
> |
draw_grids( /* draw holodeck section grids */ |
747 |
> |
int fore |
748 |
> |
) |
749 |
|
{ |
750 |
|
glPushAttrib(GL_LIGHTING_BIT|GL_ENABLE_BIT); |
751 |
|
glDisable(GL_LIGHTING); |
761 |
|
} |
762 |
|
|
763 |
|
|
764 |
< |
static |
765 |
< |
moveview(dx, dy, mov, orb) /* move our view */ |
766 |
< |
int dx, dy, mov, orb; |
764 |
> |
static int |
765 |
> |
moveview( /* move our view */ |
766 |
> |
int dx, |
767 |
> |
int dy, |
768 |
> |
int mov, |
769 |
> |
int orb |
770 |
> |
) |
771 |
|
{ |
772 |
|
VIEW nv; |
773 |
|
FVECT odir, v1, wip; |
774 |
< |
double d, d1; |
775 |
< |
register int li; |
774 |
> |
double d; |
775 |
> |
#ifdef DOBJ |
776 |
> |
double d1; |
777 |
> |
#endif |
778 |
|
/* start with old view */ |
779 |
< |
copystruct(&nv, &odev.v); |
779 |
> |
nv = odev.v; |
780 |
|
/* orient our motion */ |
781 |
|
if (viewray(v1, odir, &odev.v, |
782 |
|
(dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY) |
799 |
|
VSUM(nv.vp, wip, odir, -1.); |
800 |
|
spinvector(nv.vdir, nv.vdir, nv.vup, d); |
801 |
|
} else if (orb) { /* orbit up/down */ |
802 |
< |
fcross(v1, odir, nv.vup); |
803 |
< |
if (normalize(v1) == 0.) |
802 |
> |
if (geodesic(odir, odir, nv.vup, |
803 |
> |
d=MOVDEG*PI/180.*orb, GEOD_RAD) == 0.0) |
804 |
|
return(0); |
751 |
– |
spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb); |
805 |
|
VSUM(nv.vp, wip, odir, -1.); |
806 |
< |
spinvector(nv.vdir, nv.vdir, v1, d); |
806 |
> |
geodesic(nv.vdir, nv.vdir, nv.vup, d, GEOD_RAD); |
807 |
|
} else if (mov) { /* move forward/backward */ |
808 |
|
d = MOVPCT/100. * mov; |
809 |
|
VSUM(nv.vp, nv.vp, odir, d); |
821 |
|
} |
822 |
|
|
823 |
|
|
824 |
< |
static |
825 |
< |
getframe(ebut) /* get focus frame */ |
826 |
< |
XButtonPressedEvent *ebut; |
824 |
> |
static void |
825 |
> |
getframe( /* get focus frame */ |
826 |
> |
XButtonPressedEvent *ebut |
827 |
> |
) |
828 |
|
{ |
829 |
|
int startx = ebut->x, starty = ebut->y; |
830 |
< |
int endx, endy; |
831 |
< |
|
830 |
> |
int endx, endy, midx, midy; |
831 |
> |
FVECT odir, v1; |
832 |
> |
double d; |
833 |
> |
#ifdef DOBJ |
834 |
> |
double d1; |
835 |
> |
#endif |
836 |
> |
/* get mouse drag */ |
837 |
|
XMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent)); |
838 |
|
endx = levptr(XButtonReleasedEvent)->x; |
839 |
|
endy = levptr(XButtonReleasedEvent)->y; |
840 |
< |
if (endx == startx | endy == starty) { |
841 |
< |
XBell(ourdisplay, 0); |
840 |
> |
midx = (startx + endx) >> 1; |
841 |
> |
midy = (starty + endy) >> 1; |
842 |
> |
/* set focus distance */ |
843 |
> |
if (viewray(v1, odir, &odev.v, |
844 |
> |
(midx+.5)/odev.hres, (midy+.5)/odev.vres) < -FTINY) |
845 |
|
return; |
846 |
< |
} |
847 |
< |
if (endx < startx) {register int c = endx; endx = startx; startx = c;} |
848 |
< |
if (endy < starty) {register int c = endy; endy = starty; starty = c;} |
846 |
> |
d = getdistance(midx, midy, odir); /* distance from front plane */ |
847 |
> |
#ifdef DOBJ |
848 |
> |
d1 = dobj_trace(NULL, v1, odir); |
849 |
> |
if (d1 < d) |
850 |
> |
d = d1; |
851 |
> |
#endif |
852 |
> |
if (d < .99*FHUGE) |
853 |
> |
odev.v.vdist = d + sqrt(dist2(v1, odev.v.vp)); |
854 |
> |
/* set frame for rendering */ |
855 |
> |
if ((endx == startx) | (endy == starty)) |
856 |
> |
return; |
857 |
> |
if (endx < startx) {int c = endx; endx = startx; startx = c;} |
858 |
> |
if (endy < starty) {int c = endy; endy = starty; starty = c;} |
859 |
|
sprintf(odev_args, "%.3f %.3f %.3f %.3f", |
860 |
|
(startx+.5)/odev.hres, 1.-(endy+.5)/odev.vres, |
861 |
|
(endx+.5)/odev.hres, 1.-(starty+.5)/odev.vres); |
863 |
|
} |
864 |
|
|
865 |
|
|
866 |
< |
static |
867 |
< |
getmove(ebut) /* get view change */ |
796 |
< |
XButtonPressedEvent *ebut; |
866 |
> |
static void |
867 |
> |
waitabit(void) /* pause a moment */ |
868 |
|
{ |
869 |
+ |
struct timespec ts; |
870 |
+ |
ts.tv_sec = 0; |
871 |
+ |
ts.tv_nsec = 100000000L; |
872 |
+ |
nanosleep(&ts, NULL); |
873 |
+ |
} |
874 |
+ |
|
875 |
+ |
|
876 |
+ |
static void |
877 |
+ |
getmove( /* get view change */ |
878 |
+ |
XButtonPressedEvent *ebut |
879 |
+ |
) |
880 |
+ |
{ |
881 |
|
int movdir = MOVDIR(ebut->button); |
882 |
|
int movorb = MOVORB(ebut->state); |
883 |
|
int ndrawn; |
891 |
|
setglpersp(); /* start us off in perspective */ |
892 |
|
while (!XCheckMaskEvent(ourdisplay, |
893 |
|
ButtonReleaseMask, levptr(XEvent))) { |
894 |
+ |
/* pause so as not to move too fast */ |
895 |
+ |
waitabit(); |
896 |
|
/* get cursor position */ |
897 |
|
if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw, |
898 |
|
&rootx, &rooty, &wx, &wy, &statemask)) |
931 |
|
} |
932 |
|
|
933 |
|
|
934 |
< |
static |
935 |
< |
setglpersp() /* set perspective view in GL */ |
934 |
> |
static void |
935 |
> |
setglpersp(void) /* set perspective view in GL */ |
936 |
|
{ |
937 |
|
double d, xmin, xmax, ymin, ymax; |
938 |
|
GLfloat vec[4]; |
952 |
|
dev_zmin = odev.v.vfore; |
953 |
|
if (odev.v.vaft > FTINY) |
954 |
|
dev_zmax = odev.v.vaft; |
955 |
< |
if (dev_zmin < dev_zmax/100.) |
956 |
< |
dev_zmin = dev_zmax/100.; |
955 |
> |
if (dev_zmin*500. < dev_zmax) |
956 |
> |
dev_zmin = dev_zmax/500.; |
957 |
|
setzrat(); |
958 |
|
xmax = dev_zmin * tan(PI/180./2. * odev.v.horiz); |
959 |
|
xmin = -xmax; |
993 |
|
} |
994 |
|
|
995 |
|
|
996 |
< |
static |
997 |
< |
setglortho() /* set up orthographic view for cone drawing */ |
996 |
> |
static void |
997 |
> |
setglortho(void) /* set up orthographic view for cone drawing */ |
998 |
|
{ |
999 |
|
glDrawBuffer(GL_FRONT); /* use single-buffer mode */ |
1000 |
|
/* set view matrix */ |
1010 |
|
} |
1011 |
|
|
1012 |
|
|
1013 |
< |
static |
1014 |
< |
wipeclean() /* prepare for redraw */ |
1013 |
> |
static void |
1014 |
> |
wipeclean(void) /* prepare for redraw */ |
1015 |
|
{ |
1016 |
|
glDrawBuffer(GL_BACK); /* use double-buffer mode */ |
1017 |
|
glReadBuffer(GL_BACK); |
1029 |
|
viewflags &= ~VWCHANGE; /* change noted */ |
1030 |
|
} else if (viewflags & VWSTEADY) |
1031 |
|
odRedrawAll(); |
1032 |
< |
setglpersp(&odev.v); /* reset view & clipping planes */ |
1032 |
> |
setglpersp(); /* reset view & clipping planes */ |
1033 |
|
} |
1034 |
|
|
1035 |
|
|
1036 |
< |
static |
1037 |
< |
getkey(ekey) /* get input key */ |
1038 |
< |
register XKeyPressedEvent *ekey; |
1036 |
> |
static void |
1037 |
> |
getkey( /* get input key */ |
1038 |
> |
XKeyPressedEvent *ekey |
1039 |
> |
) |
1040 |
|
{ |
1041 |
|
Window rootw, childw; |
1042 |
|
int rootx, rooty, wx, wy; |
1117 |
|
} |
1118 |
|
|
1119 |
|
|
1120 |
< |
static |
1121 |
< |
fixwindow(eexp) /* repair damage to window */ |
1122 |
< |
register XExposeEvent *eexp; |
1120 |
> |
static void |
1121 |
> |
fixwindow( /* repair damage to window */ |
1122 |
> |
XExposeEvent *eexp |
1123 |
> |
) |
1124 |
|
{ |
1125 |
|
int xmin, ymin, xmax, ymax; |
1126 |
|
|
1127 |
< |
if (odev.hres == 0 | odev.vres == 0) { /* first exposure */ |
1127 |
> |
if ((odev.hres == 0) | (odev.vres == 0)) { /* first exposure */ |
1128 |
|
resizewindow((XConfigureEvent *)eexp); |
1129 |
|
return; |
1130 |
|
} |
1163 |
|
} |
1164 |
|
|
1165 |
|
|
1166 |
< |
static |
1167 |
< |
resizewindow(ersz) /* resize window */ |
1168 |
< |
register XConfigureEvent *ersz; |
1166 |
> |
static void |
1167 |
> |
resizewindow( /* resize window */ |
1168 |
> |
XConfigureEvent *ersz |
1169 |
> |
) |
1170 |
|
{ |
1171 |
|
glViewport(0, 0, ersz->width, ersz->height); |
1172 |
|
|