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. |
19 |
|
|
20 |
|
#include "standard.h" |
21 |
|
|
25 |
– |
#include <sys/types.h> |
22 |
|
#include <GL/glx.h> |
23 |
|
#include <GL/glu.h> |
24 |
|
#ifdef STEREO |
25 |
|
#include <X11/extensions/SGIStereo.h> |
26 |
|
#endif |
27 |
+ |
#include <time.h> |
28 |
|
|
29 |
|
#include "rhd_odraw.h" |
30 |
|
#ifdef DOBJ |
243 |
|
setstereobuf(STEREO_BUFFER_LEFT); |
244 |
|
#endif |
245 |
|
checkglerr("setting rendering parameters"); |
246 |
< |
copystruct(&odev.v, &stdview); |
246 |
> |
odev.v = stdview; |
247 |
|
odev.v.type = VT_PER; |
248 |
|
viewflags = VWSTEADY; /* view starts static */ |
249 |
|
/* map the window */ |
330 |
|
XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); |
331 |
|
dev_input(); /* get resize event */ |
332 |
|
} |
333 |
< |
copystruct(&odev.v, nv); /* setview() already called */ |
333 |
> |
odev.v = *nv; /* setview() already called */ |
334 |
|
viewflags |= VWCHANGE; |
335 |
|
} |
336 |
|
#ifdef STEREO |
337 |
< |
copystruct(&vwright, nv); |
337 |
> |
vwright = *nv; |
338 |
|
d = eyesepdist / sqrt(nv->hn2); |
339 |
|
VSUM(vwright.vp, nv->vp, nv->hvec, d); |
340 |
|
/* setview(&vwright); -- Unnecessary */ |
347 |
|
dev_section(gfn, pfn) /* add octree for geometry rendering */ |
348 |
|
char *gfn, *pfn; |
349 |
|
{ |
353 |
– |
extern char *index(); |
350 |
|
char *cp; |
351 |
|
|
352 |
|
if (gfn == NULL) { |
554 |
|
glClear(GL_DEPTH_BUFFER_BIT); /* clear system depth buffer */ |
555 |
|
odDepthMap(0, depthbuffer); /* transfer depth data */ |
556 |
|
if (pbuf != NULL) |
557 |
< |
free((char *)pbuf); /* free our portal buffer */ |
557 |
> |
free((void *)pbuf); /* free our portal buffer */ |
558 |
|
} |
559 |
|
|
560 |
|
|
565 |
|
return; |
566 |
|
#ifdef STEREO |
567 |
|
odDepthMap(1, NULL); |
568 |
< |
free((char *)depthright); |
568 |
> |
free((void *)depthright); |
569 |
|
depthright = NULL; |
570 |
|
#endif |
571 |
|
odDepthMap(0, NULL); |
572 |
< |
free((char *)depthbuffer); |
572 |
> |
free((void *)depthbuffer); |
573 |
|
depthbuffer = NULL; |
574 |
|
} |
575 |
|
|
589 |
|
else { |
590 |
|
glReadPixels(dx,dy, 1,1, GL_DEPTH_COMPONENT, |
591 |
|
GL_FLOAT, &gldepth); |
592 |
+ |
if (gldepth <= FTINY) |
593 |
+ |
return (FHUGE); /* call failed */ |
594 |
|
dist = mapdepth(gldepth); |
595 |
|
} |
596 |
|
if (dist >= .99*FHUGE) |
721 |
|
double d, d1; |
722 |
|
register int li; |
723 |
|
/* start with old view */ |
724 |
< |
copystruct(&nv, &odev.v); |
724 |
> |
nv = odev.v; |
725 |
|
/* orient our motion */ |
726 |
|
if (viewray(v1, odir, &odev.v, |
727 |
|
(dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY) |
791 |
|
|
792 |
|
|
793 |
|
static |
794 |
+ |
waitabit() /* pause a moment */ |
795 |
+ |
{ |
796 |
+ |
struct timespec ts; |
797 |
+ |
ts.tv_sec = 0; |
798 |
+ |
ts.tv_nsec = 100000000L; |
799 |
+ |
nanosleep(&ts, NULL); |
800 |
+ |
} |
801 |
+ |
|
802 |
+ |
|
803 |
+ |
static |
804 |
|
getmove(ebut) /* get view change */ |
805 |
|
XButtonPressedEvent *ebut; |
806 |
|
{ |
817 |
|
setglpersp(); /* start us off in perspective */ |
818 |
|
while (!XCheckMaskEvent(ourdisplay, |
819 |
|
ButtonReleaseMask, levptr(XEvent))) { |
820 |
+ |
/* pause so as not to move too fast */ |
821 |
+ |
waitabit(); |
822 |
|
/* get cursor position */ |
823 |
|
if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw, |
824 |
|
&rootx, &rooty, &wx, &wy, &statemask)) |
878 |
|
dev_zmin = odev.v.vfore; |
879 |
|
if (odev.v.vaft > FTINY) |
880 |
|
dev_zmax = odev.v.vaft; |
881 |
< |
if (dev_zmin < dev_zmax/100.) |
882 |
< |
dev_zmin = dev_zmax/100.; |
881 |
> |
if (dev_zmin*500. < dev_zmax) |
882 |
> |
dev_zmin = dev_zmax/500.; |
883 |
|
setzrat(); |
884 |
|
xmax = dev_zmin * tan(PI/180./2. * odev.v.horiz); |
885 |
|
xmin = -xmax; |
955 |
|
viewflags &= ~VWCHANGE; /* change noted */ |
956 |
|
} else if (viewflags & VWSTEADY) |
957 |
|
odRedrawAll(); |
958 |
< |
setglpersp(&odev.v); /* reset view & clipping planes */ |
958 |
> |
setglpersp(); /* reset view & clipping planes */ |
959 |
|
} |
960 |
|
|
961 |
|
|