1 |
– |
/* Copyright (c) 1998 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 <sys/types.h> |
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 |
36 |
|
#include "x11icon.h" |
37 |
|
|
38 |
|
#ifndef RAYQLEN |
39 |
< |
#define RAYQLEN 10240 /* max. rays to queue before flush */ |
39 |
> |
#define RAYQLEN 0 /* max. rays to queue before flush */ |
40 |
|
#endif |
41 |
< |
|
42 |
< |
#ifndef PORTALP |
43 |
< |
#define PORTRED 2 /* portal red color */ |
45 |
< |
#define PORTGRN -1 /* portal green left alone */ |
46 |
< |
#define PORTBLU 128 /* portal blue color */ |
47 |
< |
#define PORTALP -1 /* don't use alpha channel */ |
41 |
> |
#ifndef MINWIDTH |
42 |
> |
#define MINWIDTH 480 /* minimum graphics window width */ |
43 |
> |
#define MINHEIGHT 400 /* minimum graphics window height */ |
44 |
|
#endif |
45 |
< |
#define isportal(c) ((PORTRED<0 || (c)[0]==PORTRED) && \ |
46 |
< |
(PORTGRN<0 || (c)[1]==PORTGRN) && \ |
47 |
< |
(PORTBLU<0 || (c)[2]==PORTBLU) && \ |
48 |
< |
(PORTALP<0 || (c)[3]==PORTALP)) |
45 |
> |
#ifndef VIEWDIST |
46 |
> |
#define VIEWDIST 356 /* assumed viewing distance (mm) */ |
47 |
> |
#endif |
48 |
> |
#ifndef BORWIDTH |
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 |
|
|
56 |
+ |
#define VWHEADLOCK 01 /* head position is locked flag */ |
57 |
+ |
#define VWPERSP 02 /* perspective view is set */ |
58 |
+ |
#define VWORTHO 04 /* orthographic view is set */ |
59 |
+ |
#define VWCHANGE 010 /* view has changed */ |
60 |
+ |
#define VWSTEADY 020 /* view is now steady */ |
61 |
+ |
#define VWMAPPED 040 /* window is mapped */ |
62 |
+ |
|
63 |
|
#define GAMMA 1.4 /* default gamma correction */ |
64 |
|
|
65 |
|
#define FRAMESTATE(s) (((s)&(ShiftMask|ControlMask))==(ShiftMask|ControlMask)) |
69 |
|
#define MOVDEG (-5) /* degrees to orbit CW/down /frame */ |
70 |
|
#define MOVORB(s) ((s)&ShiftMask ? 1 : (s)&ControlMask ? -1 : 0) |
71 |
|
|
67 |
– |
#define MINWIDTH 480 /* minimum graphics window width */ |
68 |
– |
#define MINHEIGHT 400 /* minimum graphics window height */ |
69 |
– |
|
70 |
– |
#define VIEWDIST 356 /* assumed viewing distance (mm) */ |
71 |
– |
|
72 |
– |
#define BORWIDTH 5 /* border width */ |
73 |
– |
|
72 |
|
#define setstereobuf(bid) (glXWaitGL(), \ |
73 |
|
XSGISetStereoBuffer(ourdisplay, gwind, bid), \ |
74 |
|
glXWaitX()) |
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 */ |
97 |
|
|
98 |
|
static XEvent currentevent; /* current event */ |
99 |
|
|
100 |
– |
static int mapped = 0; /* window is mapped? */ |
100 |
|
static unsigned long ourblack=0, ourwhite=~0; |
101 |
|
|
102 |
|
static Display *ourdisplay = NULL; /* our display */ |
114 |
|
|
115 |
|
static int inpresflags; /* input result flags */ |
116 |
|
|
117 |
< |
static int headlocked; /* lock vertical motion */ |
117 |
> |
static int viewflags; /* what's happening with view */ |
118 |
|
|
119 |
< |
static int isperspective; /* perspective/ortho view */ |
121 |
< |
|
122 |
< |
static int viewsteady; /* is view steady? */ |
123 |
< |
|
119 |
> |
/* |
120 |
|
static int resizewindow(), getevent(), getkey(), moveview(), wipeclean(), |
121 |
|
xferdepth(), freedepth(), setglortho(), |
122 |
|
setglpersp(), getframe(), getmove(), fixwindow(), mytmflags(); |
123 |
|
|
124 |
|
static double getdistance(); |
125 |
+ |
*/ |
126 |
+ |
static void checkglerr(char *where); |
127 |
+ |
static void xferdepth(void); |
128 |
+ |
static void freedepth(void); |
129 |
+ |
static double getdistance(int dx, int dy, FVECT direc); |
130 |
+ |
static int mytmflags(void); |
131 |
+ |
static void getevent(void); |
132 |
+ |
static void draw3dline(register FVECT wp[2]); |
133 |
+ |
static void draw_grids(int fore); |
134 |
+ |
static int moveview(int dx, int dy, int mov, int orb); |
135 |
+ |
static void getframe(XButtonPressedEvent *ebut); |
136 |
+ |
static void getmove(XButtonPressedEvent *ebut); |
137 |
+ |
static void getkey(register XKeyPressedEvent *ekey); |
138 |
+ |
static void fixwindow(register XExposeEvent *eexp); |
139 |
+ |
static void resizewindow(register XConfigureEvent *ersz); |
140 |
+ |
static void waitabit(void); |
141 |
+ |
static void setglpersp(void); |
142 |
+ |
static void setglortho(void); |
143 |
+ |
static void wipeclean(void); |
144 |
|
|
145 |
+ |
|
146 |
|
#ifdef STEREO |
147 |
< |
static int pushright(), popright(); |
147 |
> |
static void pushright(void); |
148 |
> |
static void popright(void); |
149 |
|
#endif |
150 |
|
|
151 |
|
extern int gmPortals; /* GL portal list id */ |
153 |
|
extern time_t time(); |
154 |
|
|
155 |
|
|
156 |
+ |
extern void |
157 |
|
dev_open(id) /* initialize GLX driver */ |
158 |
|
char *id; |
159 |
|
{ |
160 |
|
extern char *getenv(); |
161 |
|
static RGBPRIMS myprims = STDPRIMS; |
162 |
< |
#if (PORTALP<0) |
163 |
< |
static int atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8, |
164 |
< |
GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8, |
165 |
< |
GLX_DEPTH_SIZE,15, None}; |
166 |
< |
#else |
167 |
< |
static int atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8, |
150 |
< |
GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8, |
151 |
< |
GLX_ALPHA_SIZE,2, GLX_DEPTH_SIZE,15, None}; |
152 |
< |
#endif |
162 |
> |
static int atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
163 |
> |
GLX_RED_SIZE,8, GLX_GREEN_SIZE,8, |
164 |
> |
GLX_BLUE_SIZE,8, GLX_DEPTH_SIZE,15, None}; |
165 |
> |
static int atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
166 |
> |
GLX_RED_SIZE,4, GLX_GREEN_SIZE,4, |
167 |
> |
GLX_BLUE_SIZE,4, GLX_DEPTH_SIZE,15, None}; |
168 |
|
char *ev; |
169 |
|
double gamval = GAMMA; |
170 |
|
RGBPRIMP dpri = stdprims; |
195 |
|
#endif |
196 |
|
/* find a usable visual */ |
197 |
|
ourvinf = glXChooseVisual(ourdisplay, ourscreen, atlBest); |
198 |
+ |
if (ourvinf == NULL) |
199 |
+ |
ourvinf = glXChooseVisual(ourdisplay, ourscreen, atlOK); |
200 |
|
CHECK(ourvinf==NULL, USER, "no suitable visuals available"); |
201 |
|
/* get a context */ |
202 |
|
gctx = glXCreateContext(ourdisplay, ourvinf, NULL, GL_TRUE); |
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; |
254 |
|
glXMakeCurrent(ourdisplay, gwind, gctx); |
255 |
|
glEnable(GL_DEPTH_TEST); |
256 |
|
glDepthFunc(GL_LEQUAL); |
257 |
< |
glDisable(GL_DITHER); |
257 |
> |
glClearColor(0, 0, 0, 0); |
258 |
|
glFrontFace(GL_CCW); |
259 |
|
glDisable(GL_CULL_FACE); |
260 |
|
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
261 |
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); |
262 |
+ |
glPixelStorei(GL_PACK_ALIGNMENT, 1); |
263 |
+ |
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
264 |
|
/* figure out sensible view */ |
265 |
|
pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / |
266 |
|
DisplayWidth(ourdisplay, ourscreen); |
271 |
|
setstereobuf(STEREO_BUFFER_LEFT); |
272 |
|
#endif |
273 |
|
checkglerr("setting rendering parameters"); |
274 |
< |
copystruct(&odev.v, &stdview); |
274 |
> |
odev.v = stdview; |
275 |
|
odev.v.type = VT_PER; |
276 |
< |
headlocked = 0; /* free up head movement */ |
257 |
< |
viewsteady = 1; /* view starts static */ |
258 |
< |
isperspective = -1; /* but no view set, yet */ |
276 |
> |
viewflags = VWSTEADY; /* view starts static */ |
277 |
|
/* map the window */ |
278 |
|
XMapWindow(ourdisplay, gwind); |
279 |
|
dev_input(); /* sets size and view angles */ |
280 |
|
if (!odInit(DisplayWidth(ourdisplay,ourscreen) * |
281 |
< |
DisplayHeight(ourdisplay,ourscreen) / 4)) |
281 |
> |
DisplayHeight(ourdisplay,ourscreen) / 3)) |
282 |
|
error(SYSTEM, "insufficient memory for value storage"); |
283 |
|
odev.name = id; |
284 |
|
odev.firstuse = 1; /* can't recycle samples */ |
286 |
|
} |
287 |
|
|
288 |
|
|
289 |
< |
dev_close() /* close our display and free resources */ |
289 |
> |
extern void |
290 |
> |
dev_close(void) /* close our display and free resources */ |
291 |
|
{ |
292 |
|
#ifdef DOBJ |
293 |
|
dobj_cleanup(); |
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; |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
< |
dev_clear() /* clear our representation */ |
312 |
> |
extern void |
313 |
> |
dev_clear(void) /* clear our representation */ |
314 |
|
{ |
315 |
< |
wipeclean(); |
315 |
> |
viewflags |= VWCHANGE; /* pretend our view has changed */ |
316 |
> |
wipeclean(); /* clean off display and samples */ |
317 |
> |
dev_flush(); /* redraw geometry & get depth */ |
318 |
|
rayqleft = 0; /* hold off update */ |
319 |
|
} |
320 |
|
|
321 |
|
|
322 |
< |
int |
323 |
< |
dev_view(nv) /* assign new driver view */ |
324 |
< |
register VIEW *nv; |
322 |
> |
extern int |
323 |
> |
dev_view( /* assign new driver view */ |
324 |
> |
register VIEW *nv |
325 |
> |
) |
326 |
|
{ |
304 |
– |
double d; |
305 |
– |
|
327 |
|
if (nv->type != VT_PER || /* check view legality */ |
328 |
|
nv->horiz > 160. || nv->vert > 160.) { |
329 |
|
error(COMMAND, "illegal view type/angle"); |
359 |
|
XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); |
360 |
|
dev_input(); /* get resize event */ |
361 |
|
} |
362 |
< |
copystruct(&odev.v, nv); /* setview() already called */ |
362 |
> |
odev.v = *nv; /* setview() already called */ |
363 |
> |
viewflags |= VWCHANGE; |
364 |
> |
} |
365 |
|
#ifdef STEREO |
366 |
< |
copystruct(&vwright, nv); |
367 |
< |
d = eyesepdist / sqrt(nv->hn2); |
368 |
< |
VSUM(vwright.vp, nv->vp, nv->hvec, d); |
369 |
< |
/* setview(&vwright); -- Unnecessary */ |
366 |
> |
vwright = *nv; |
367 |
> |
d = eyesepdist / sqrt(nv->hn2); |
368 |
> |
VSUM(vwright.vp, nv->vp, nv->hvec, d); |
369 |
> |
/* setview(&vwright); -- Unnecessary */ |
370 |
|
#endif |
348 |
– |
} else |
349 |
– |
viewsteady = 1; |
371 |
|
wipeclean(); |
372 |
|
return(1); |
373 |
|
} |
374 |
|
|
375 |
|
|
376 |
< |
dev_section(gfn, pfn) /* add octree for geometry rendering */ |
377 |
< |
char *gfn, *pfn; |
376 |
> |
extern void |
377 |
> |
dev_section( /* add octree for geometry rendering */ |
378 |
> |
char *gfn, |
379 |
> |
char *pfn |
380 |
> |
) |
381 |
|
{ |
358 |
– |
extern char *index(); |
359 |
– |
char *cp; |
360 |
– |
|
382 |
|
if (gfn == NULL) { |
383 |
|
gmEndGeom(); |
384 |
|
gmEndPortal(); |
398 |
|
} |
399 |
|
|
400 |
|
|
401 |
< |
dev_auxcom(cmd, args) /* process an auxiliary command */ |
402 |
< |
char *cmd, *args; |
401 |
> |
extern void |
402 |
> |
dev_auxcom( /* process an auxiliary command */ |
403 |
> |
char *cmd, |
404 |
> |
char *args |
405 |
> |
) |
406 |
|
{ |
407 |
|
#ifdef DOBJ |
408 |
< |
if (dobj_command(cmd, args) >= 0) |
408 |
> |
int vischange; |
409 |
> |
|
410 |
> |
if ((vischange = dobj_command(cmd, args)) >= 0) { |
411 |
> |
if (vischange) { |
412 |
> |
imm_mode = beam_sync(1) > 0; |
413 |
> |
dev_clear(); |
414 |
> |
} |
415 |
|
return; |
416 |
+ |
} |
417 |
|
#endif |
418 |
|
sprintf(errmsg, "%s: unknown command", cmd); |
419 |
|
error(COMMAND, errmsg); |
420 |
|
} |
421 |
|
|
422 |
|
|
423 |
< |
VIEW * |
424 |
< |
dev_auxview(n, hvres) /* return nth auxiliary view */ |
425 |
< |
int n; |
426 |
< |
int hvres[2]; |
423 |
> |
extern VIEW * |
424 |
> |
dev_auxview( /* return nth auxiliary view */ |
425 |
> |
int n, |
426 |
> |
int hvres[2] |
427 |
> |
) |
428 |
|
{ |
429 |
|
hvres[0] = odev.hres; hvres[1] = odev.vres; |
430 |
|
if (n == 0) |
437 |
|
} |
438 |
|
|
439 |
|
|
440 |
< |
int |
441 |
< |
dev_input() /* get X11 input */ |
440 |
> |
extern int |
441 |
> |
dev_input(void) /* get X11 input */ |
442 |
|
{ |
443 |
|
inpresflags = 0; |
444 |
|
|
453 |
|
} |
454 |
|
|
455 |
|
|
456 |
< |
dev_value(c, d, p) /* add a pixel value to our texture */ |
457 |
< |
COLR c; |
458 |
< |
FVECT d, p; |
456 |
> |
extern void |
457 |
> |
dev_value( /* add a pixel value to our texture */ |
458 |
> |
COLR c, |
459 |
> |
FVECT d, |
460 |
> |
FVECT p |
461 |
> |
) |
462 |
|
{ |
463 |
|
#ifdef DOBJ |
464 |
|
if (dobj_lightsamp != NULL) { /* in light source sampling */ |
472 |
|
} |
473 |
|
|
474 |
|
|
475 |
< |
int |
476 |
< |
dev_flush() /* flush output as appropriate */ |
475 |
> |
extern int |
476 |
> |
dev_flush(void) /* flush output as appropriate */ |
477 |
|
{ |
478 |
|
int ndrawn; |
479 |
|
|
480 |
< |
if (mapped && isperspective > 0) { |
480 |
> |
if ((viewflags&(VWMAPPED|VWPERSP)) == (VWMAPPED|VWPERSP)) { |
481 |
|
#ifdef STEREO |
482 |
|
pushright(); /* draw right eye */ |
483 |
|
ndrawn = gmDrawGeom(); |
484 |
|
#ifdef DOBJ |
485 |
|
ndrawn += dobj_render(); |
486 |
|
#endif |
452 |
– |
if (ndrawn) |
453 |
– |
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
487 |
|
checkglerr("rendering right eye"); |
488 |
|
popright(); /* draw left eye */ |
489 |
|
#endif |
491 |
|
#ifdef DOBJ |
492 |
|
ndrawn += dobj_render(); |
493 |
|
#endif |
494 |
< |
if (ndrawn) |
462 |
< |
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
494 |
> |
glXSwapBuffers(ourdisplay, gwind); |
495 |
|
checkglerr("rendering base view"); |
496 |
|
} |
497 |
< |
if (mapped && viewsteady) |
498 |
< |
if (isperspective > 0) { /* first time after steady */ |
499 |
< |
if (ndrawn) |
500 |
< |
xferdepth(); /* transfer and clear depth */ |
501 |
< |
setglortho(); /* set orthographic view */ |
502 |
< |
} else if (!isperspective) { |
497 |
> |
if ((viewflags&(VWMAPPED|VWSTEADY|VWPERSP|VWORTHO)) == |
498 |
> |
(VWMAPPED|VWSTEADY|VWPERSP)) { |
499 |
> |
/* first time after steady */ |
500 |
> |
if (ndrawn) |
501 |
> |
xferdepth(); /* transfer and clear depth */ |
502 |
> |
setglortho(); /* set orthographic view */ |
503 |
> |
|
504 |
> |
} |
505 |
> |
if ((viewflags&(VWMAPPED|VWSTEADY|VWPERSP|VWORTHO)) == |
506 |
> |
(VWMAPPED|VWSTEADY|VWORTHO)) { |
507 |
> |
/* else update cones */ |
508 |
|
#ifdef STEREO |
509 |
< |
pushright(); |
510 |
< |
odUpdate(1); /* draw right eye */ |
511 |
< |
popright(); |
509 |
> |
pushright(); |
510 |
> |
odUpdate(1); /* draw right eye */ |
511 |
> |
popright(); |
512 |
|
#endif |
513 |
< |
odUpdate(0); /* draw left eye */ |
514 |
< |
} |
515 |
< |
glFlush(); /* flush OpenGL */ |
513 |
> |
odUpdate(0); /* draw left eye */ |
514 |
> |
glFlush(); /* flush OpenGL */ |
515 |
> |
} |
516 |
|
rayqleft = RAYQLEN; |
517 |
|
/* flush X11 and return # pending */ |
518 |
|
return(odev.inpready = XPending(ourdisplay)); |
519 |
|
} |
520 |
|
|
521 |
|
|
522 |
< |
checkglerr(where) /* check for GL or GLU error */ |
523 |
< |
char *where; |
522 |
> |
static void |
523 |
> |
checkglerr( /* check for GL or GLU error */ |
524 |
> |
char *where |
525 |
> |
) |
526 |
|
{ |
527 |
|
register GLenum errcode; |
528 |
|
|
534 |
|
} |
535 |
|
|
536 |
|
|
537 |
< |
static |
538 |
< |
xferdepth() /* load and clear depth buffer */ |
537 |
> |
static void |
538 |
> |
xferdepth(void) /* load and clear depth buffer */ |
539 |
|
{ |
540 |
|
register GLfloat *dbp; |
541 |
< |
register GLubyte *cbuf; |
541 |
> |
register GLubyte *pbuf; |
542 |
|
|
543 |
|
if (depthbuffer == NULL) { /* allocate private depth buffer */ |
544 |
|
#ifdef STEREO |
551 |
|
} |
552 |
|
/* allocate alpha buffer for portals */ |
553 |
|
if (gmPortals) |
554 |
< |
cbuf = (GLubyte *)malloc(odev.hres*odev.vres* |
516 |
< |
(4*sizeof(GLubyte))); |
554 |
> |
pbuf = (GLubyte *)malloc(odev.hres*odev.vres*sizeof(GLubyte)); |
555 |
|
else |
556 |
< |
cbuf = NULL; |
556 |
> |
pbuf = NULL; |
557 |
|
#ifdef STEREO |
558 |
< |
setstereobuf(STEREO_BUFFER_RIGHT); |
558 |
> |
pushright(); |
559 |
|
glReadPixels(0, 0, odev.hres, odev.vres, |
560 |
|
GL_DEPTH_COMPONENT, GL_FLOAT, depthright); |
561 |
< |
if (cbuf != NULL) |
561 |
> |
if (pbuf != NULL) { |
562 |
> |
glClear(GL_COLOR_BUFFER_BIT); |
563 |
> |
gmDrawPortals(0xff, -1, -1, -1); |
564 |
|
glReadPixels(0, 0, odev.hres, odev.vres, |
565 |
< |
GL_RGBA, GL_UNSIGNED_BYTE, cbuf); |
565 |
> |
GL_RED, GL_UNSIGNED_BYTE, pbuf); |
566 |
> |
} |
567 |
|
for (dbp = depthright + odev.hres*odev.vres; dbp-- > depthright; ) |
568 |
< |
if (cbuf != NULL && isportal(cbuf+4*(dbp-depthright))) |
568 |
> |
if (pbuf != NULL && pbuf[dbp-depthright]&0x40) |
569 |
|
*dbp = FHUGE; |
570 |
|
else |
571 |
|
*dbp = mapdepth(*dbp); |
572 |
|
glClear(GL_DEPTH_BUFFER_BIT); |
532 |
– |
setstereobuf(STEREO_BUFFER_LEFT); |
573 |
|
odDepthMap(1, depthright); |
574 |
+ |
popright(); |
575 |
|
#endif |
576 |
|
/* read back depth buffer */ |
577 |
|
glReadPixels(0, 0, odev.hres, odev.vres, |
578 |
|
GL_DEPTH_COMPONENT, GL_FLOAT, depthbuffer); |
579 |
< |
if (cbuf != NULL) |
579 |
> |
if (pbuf != NULL) { |
580 |
> |
glClear(GL_COLOR_BUFFER_BIT); /* find portals */ |
581 |
> |
gmDrawPortals(0xff, -1, -1, -1); |
582 |
|
glReadPixels(0, 0, odev.hres, odev.vres, |
583 |
< |
GL_RGBA, GL_UNSIGNED_BYTE, cbuf); |
583 |
> |
GL_RED, GL_UNSIGNED_BYTE, pbuf); |
584 |
> |
#ifdef DEBUG |
585 |
> |
glXSwapBuffers(ourdisplay, gwind); |
586 |
> |
#endif |
587 |
> |
} |
588 |
|
for (dbp = depthbuffer + odev.hres*odev.vres; dbp-- > depthbuffer; ) |
589 |
< |
if (cbuf != NULL && isportal(cbuf+4*(dbp-depthbuffer))) |
589 |
> |
if (pbuf != NULL && pbuf[dbp-depthbuffer]&0x40) |
590 |
|
*dbp = FHUGE; |
591 |
|
else |
592 |
|
*dbp = mapdepth(*dbp); |
593 |
|
glClear(GL_DEPTH_BUFFER_BIT); /* clear system depth buffer */ |
547 |
– |
if (cbuf != NULL) |
548 |
– |
free((char *)cbuf); /* free our color buffer */ |
594 |
|
odDepthMap(0, depthbuffer); /* transfer depth data */ |
595 |
+ |
if (pbuf != NULL) |
596 |
+ |
free((void *)pbuf); /* free our portal buffer */ |
597 |
|
} |
598 |
|
|
599 |
|
|
600 |
< |
static |
601 |
< |
freedepth() /* free recorded depth buffer */ |
600 |
> |
static void |
601 |
> |
freedepth(void) /* free recorded depth buffer */ |
602 |
|
{ |
603 |
|
if (depthbuffer == NULL) |
604 |
|
return; |
605 |
|
#ifdef STEREO |
606 |
|
odDepthMap(1, NULL); |
607 |
< |
free((char *)depthright); |
607 |
> |
free((void *)depthright); |
608 |
|
depthright = NULL; |
609 |
|
#endif |
610 |
|
odDepthMap(0, NULL); |
611 |
< |
free((char *)depthbuffer); |
611 |
> |
free((void *)depthbuffer); |
612 |
|
depthbuffer = NULL; |
613 |
|
} |
614 |
|
|
615 |
|
|
616 |
|
static double |
617 |
< |
getdistance(dx, dy, direc) /* distance from fore plane along view ray */ |
618 |
< |
int dx, dy; |
619 |
< |
FVECT direc; |
617 |
> |
getdistance( /* distance from fore plane along view ray */ |
618 |
> |
int dx, |
619 |
> |
int dy, |
620 |
> |
FVECT direc |
621 |
> |
) |
622 |
|
{ |
623 |
|
GLfloat gldepth; |
575 |
– |
GLubyte glcolor[4]; |
624 |
|
double dist; |
625 |
|
|
626 |
< |
if (dx<0 | dx>=odev.hres | dy<0 | dy>=odev.vres) |
626 |
> |
if ((dx<0) | (dx>=odev.hres) | (dy<0) | (dy>=odev.vres)) |
627 |
|
return(FHUGE); |
628 |
|
if (depthbuffer != NULL) |
629 |
|
dist = depthbuffer[dy*odev.hres + dx]; |
630 |
|
else { |
631 |
|
glReadPixels(dx,dy, 1,1, GL_DEPTH_COMPONENT, |
632 |
|
GL_FLOAT, &gldepth); |
633 |
< |
if (gmPortals) { |
634 |
< |
glReadPixels(dx,dy, 1,1, GL_RGBA, |
587 |
< |
GL_UNSIGNED_BYTE, glcolor); |
588 |
< |
if (isportal(glcolor)) |
589 |
< |
return(FHUGE); |
590 |
< |
} |
633 |
> |
if (gldepth <= FTINY) |
634 |
> |
return (FHUGE); /* call failed */ |
635 |
|
dist = mapdepth(gldepth); |
636 |
|
} |
637 |
|
if (dist >= .99*FHUGE) |
641 |
|
|
642 |
|
|
643 |
|
#ifdef STEREO |
644 |
< |
static |
645 |
< |
pushright() /* push on right view & buffer */ |
644 |
> |
static void |
645 |
> |
pushright(void) /* push on right view & buffer */ |
646 |
|
{ |
647 |
|
double d; |
648 |
|
|
649 |
|
setstereobuf(STEREO_BUFFER_RIGHT); |
650 |
< |
if (isperspective > 0) { |
650 |
> |
if (viewflags & VWPERSP) { |
651 |
|
glMatrixMode(GL_MODELVIEW); |
652 |
|
glPushMatrix(); |
653 |
|
d = -eyesepdist / sqrt(odev.v.hn2); |
658 |
|
} |
659 |
|
|
660 |
|
|
661 |
< |
static |
662 |
< |
popright() /* pop off right view & buffer */ |
661 |
> |
static void |
662 |
> |
popright(void) /* pop off right view & buffer */ |
663 |
|
{ |
664 |
< |
if (isperspective > 0) { |
664 |
> |
if (viewflags & VWPERSP) { |
665 |
|
glMatrixMode(GL_MODELVIEW); |
666 |
|
glPopMatrix(); |
667 |
|
} |
671 |
|
|
672 |
|
|
673 |
|
static int |
674 |
< |
mytmflags() /* figure out tone mapping flags */ |
674 |
> |
mytmflags(void) /* figure out tone mapping flags */ |
675 |
|
{ |
676 |
|
extern char *progname; |
677 |
|
register char *cp, *tail; |
695 |
|
} |
696 |
|
|
697 |
|
|
698 |
< |
static |
699 |
< |
getevent() /* get next event */ |
698 |
> |
static void |
699 |
> |
getevent(void) /* get next event */ |
700 |
|
{ |
701 |
|
XNextEvent(ourdisplay, levptr(XEvent)); |
702 |
|
switch (levptr(XEvent)->type) { |
704 |
|
resizewindow(levptr(XConfigureEvent)); |
705 |
|
break; |
706 |
|
case UnmapNotify: |
707 |
< |
mapped = 0; |
707 |
> |
viewflags &= ~VWMAPPED; |
708 |
|
break; |
709 |
|
case MapNotify: |
710 |
|
odRemap(0); |
711 |
< |
mapped = 1; |
711 |
> |
viewflags |= VWMAPPED; |
712 |
|
break; |
713 |
|
case Expose: |
714 |
|
fixwindow(levptr(XExposeEvent)); |
726 |
|
} |
727 |
|
|
728 |
|
|
729 |
< |
static |
730 |
< |
draw3dline(wp) /* draw 3d line in world coordinates */ |
731 |
< |
register FVECT wp[2]; |
729 |
> |
static void |
730 |
> |
draw3dline( /* draw 3d line in world coordinates */ |
731 |
> |
register FVECT wp[2] |
732 |
> |
) |
733 |
|
{ |
734 |
|
glVertex3d(wp[0][0], wp[0][1], wp[0][2]); |
735 |
|
glVertex3d(wp[1][0], wp[1][1], wp[1][2]); |
736 |
|
} |
737 |
|
|
738 |
|
|
739 |
< |
static |
740 |
< |
draw_grids(fore) /* draw holodeck section grids */ |
741 |
< |
int fore; |
739 |
> |
static void |
740 |
> |
draw_grids( /* draw holodeck section grids */ |
741 |
> |
int fore |
742 |
> |
) |
743 |
|
{ |
744 |
|
glPushAttrib(GL_LIGHTING_BIT|GL_ENABLE_BIT); |
745 |
|
glDisable(GL_LIGHTING); |
746 |
|
if (fore) |
747 |
< |
glColor3ub(0, 255, 255); |
747 |
> |
glColor3ub(4, 250, 250); |
748 |
|
else |
749 |
|
glColor3ub(0, 0, 0); |
750 |
|
glBegin(GL_LINES); /* draw each grid line */ |
755 |
|
} |
756 |
|
|
757 |
|
|
758 |
< |
static |
759 |
< |
moveview(dx, dy, mov, orb) /* move our view */ |
760 |
< |
int dx, dy, mov, orb; |
758 |
> |
static int |
759 |
> |
moveview( /* move our view */ |
760 |
> |
int dx, |
761 |
> |
int dy, |
762 |
> |
int mov, |
763 |
> |
int orb |
764 |
> |
) |
765 |
|
{ |
766 |
|
VIEW nv; |
767 |
|
FVECT odir, v1, wip; |
768 |
|
double d, d1; |
719 |
– |
register int li; |
769 |
|
/* start with old view */ |
770 |
< |
copystruct(&nv, &odev.v); |
770 |
> |
nv = odev.v; |
771 |
|
/* orient our motion */ |
772 |
|
if (viewray(v1, odir, &odev.v, |
773 |
|
(dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY) |
800 |
|
d = MOVPCT/100. * mov; |
801 |
|
VSUM(nv.vp, nv.vp, odir, d); |
802 |
|
} |
803 |
< |
if (!mov ^ !orb && headlocked) { /* restore head height */ |
803 |
> |
if (!mov ^ !orb && viewflags&VWHEADLOCK) { /* restore height */ |
804 |
|
VSUM(v1, odev.v.vp, nv.vp, -1.); |
805 |
|
d = DOT(v1, nv.vup); |
806 |
|
VSUM(nv.vp, nv.vp, odev.v.vup, d); |
813 |
|
} |
814 |
|
|
815 |
|
|
816 |
< |
static |
817 |
< |
getframe(ebut) /* get focus frame */ |
818 |
< |
XButtonPressedEvent *ebut; |
816 |
> |
static void |
817 |
> |
getframe( /* get focus frame */ |
818 |
> |
XButtonPressedEvent *ebut |
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", |
852 |
|
} |
853 |
|
|
854 |
|
|
855 |
< |
static |
856 |
< |
getmove(ebut) /* get view change */ |
792 |
< |
XButtonPressedEvent *ebut; |
855 |
> |
static void |
856 |
> |
waitabit(void) /* pause a moment */ |
857 |
|
{ |
858 |
+ |
struct timespec ts; |
859 |
+ |
ts.tv_sec = 0; |
860 |
+ |
ts.tv_nsec = 100000000L; |
861 |
+ |
nanosleep(&ts, NULL); |
862 |
+ |
} |
863 |
+ |
|
864 |
+ |
|
865 |
+ |
static void |
866 |
+ |
getmove( /* get view change */ |
867 |
+ |
XButtonPressedEvent *ebut |
868 |
+ |
) |
869 |
+ |
{ |
870 |
|
int movdir = MOVDIR(ebut->button); |
871 |
|
int movorb = MOVORB(ebut->state); |
872 |
|
int ndrawn; |
876 |
|
|
877 |
|
XNoOp(ourdisplay); /* makes sure we're not idle */ |
878 |
|
|
879 |
< |
viewsteady = 0; /* flag moving view */ |
880 |
< |
setglpersp(&odev.v); /* start us off in perspective */ |
879 |
> |
viewflags &= ~VWSTEADY; /* flag moving view */ |
880 |
> |
setglpersp(); /* start us off in perspective */ |
881 |
|
while (!XCheckMaskEvent(ourdisplay, |
882 |
|
ButtonReleaseMask, levptr(XEvent))) { |
883 |
+ |
/* pause so as not to move too fast */ |
884 |
+ |
waitabit(); |
885 |
|
/* get cursor position */ |
886 |
|
if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw, |
887 |
|
&rootx, &rooty, &wx, &wy, &statemask)) |
899 |
|
#ifdef DOBJ |
900 |
|
ndrawn += dobj_render(); |
901 |
|
#endif |
824 |
– |
if (ndrawn) |
825 |
– |
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
902 |
|
popright(); |
903 |
|
#endif |
904 |
|
/* redraw octrees */ |
906 |
|
#ifdef DOBJ |
907 |
|
ndrawn += dobj_render(); /* redraw objects */ |
908 |
|
#endif |
909 |
< |
if (ndrawn) |
910 |
< |
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
835 |
< |
glFlush(); |
836 |
< |
if (!ndrawn) { |
909 |
> |
glXSwapBuffers(ourdisplay, gwind); |
910 |
> |
if (!ndrawn) |
911 |
|
sleep(1); /* for reasonable interaction */ |
838 |
– |
#ifdef STEREO |
839 |
– |
pushright(); |
840 |
– |
draw_grids(0); |
841 |
– |
popright(); |
842 |
– |
#endif |
843 |
– |
draw_grids(0); |
844 |
– |
} |
912 |
|
} |
913 |
|
if (!(inpresflags & DFL(DC_SETVIEW))) { /* do final motion */ |
914 |
|
movdir = MOVDIR(levptr(XButtonReleasedEvent)->button); |
916 |
|
wy = levptr(XButtonReleasedEvent)->y; |
917 |
|
moveview(wx, odev.vres-1-wy, movdir, movorb); |
918 |
|
} |
919 |
+ |
viewflags |= VWSTEADY; /* done goofing around */ |
920 |
|
} |
921 |
|
|
922 |
|
|
923 |
< |
static |
924 |
< |
setglpersp(vp) /* set perspective view in GL */ |
857 |
< |
register VIEW *vp; |
923 |
> |
static void |
924 |
> |
setglpersp(void) /* set perspective view in GL */ |
925 |
|
{ |
926 |
|
double d, xmin, xmax, ymin, ymax; |
927 |
|
GLfloat vec[4]; |
933 |
|
dev_zmax = 100.; |
934 |
|
} else { |
935 |
|
dev_zmin = 0.5*depthlim[0]; |
936 |
< |
dev_zmax = 1.75*depthlim[1]; |
936 |
> |
dev_zmax = 1.25*depthlim[1]; |
937 |
|
if (dev_zmin > dev_zmax/5.) |
938 |
|
dev_zmin = dev_zmax/5.; |
939 |
|
} |
941 |
|
dev_zmin = odev.v.vfore; |
942 |
|
if (odev.v.vaft > FTINY) |
943 |
|
dev_zmax = odev.v.vaft; |
944 |
< |
if (dev_zmin < dev_zmax/100.) |
945 |
< |
dev_zmin = dev_zmax/100.; |
944 |
> |
if (dev_zmin*500. < dev_zmax) |
945 |
> |
dev_zmin = dev_zmax/500.; |
946 |
|
setzrat(); |
947 |
|
xmax = dev_zmin * tan(PI/180./2. * odev.v.horiz); |
948 |
|
xmin = -xmax; |
962 |
|
odev.v.vp[2] + odev.v.vdir[2], |
963 |
|
odev.v.vup[0], odev.v.vup[1], odev.v.vup[2]); |
964 |
|
checkglerr("setting perspective view"); |
898 |
– |
isperspective = 1; |
965 |
|
vec[0] = vec[1] = vec[2] = 0.; vec[3] = 1.; |
966 |
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, vec); |
967 |
|
vec[0] = -odev.v.vdir[0]; |
977 |
|
glEnable(GL_LIGHT0); |
978 |
|
glEnable(GL_LIGHTING); /* light our GL objects */ |
979 |
|
glShadeModel(GL_SMOOTH); |
980 |
+ |
viewflags &= ~VWORTHO; |
981 |
+ |
viewflags |= VWPERSP; |
982 |
|
} |
983 |
|
|
984 |
|
|
985 |
< |
static |
986 |
< |
setglortho() /* set up orthographic view for cone drawing */ |
985 |
> |
static void |
986 |
> |
setglortho(void) /* set up orthographic view for cone drawing */ |
987 |
|
{ |
988 |
+ |
glDrawBuffer(GL_FRONT); /* use single-buffer mode */ |
989 |
|
/* set view matrix */ |
990 |
|
glMatrixMode(GL_PROJECTION); |
991 |
|
glLoadIdentity(); |
992 |
|
glOrtho(0., (double)odev.hres, 0., (double)odev.vres, |
993 |
|
0.001*OMAXDEPTH, 1.001*(-OMAXDEPTH)); |
994 |
|
checkglerr("setting orthographic view"); |
926 |
– |
isperspective = 0; |
995 |
|
glDisable(GL_LIGHTING); /* cones are constant color */ |
996 |
|
glShadeModel(GL_FLAT); |
997 |
+ |
viewflags &= ~VWPERSP; |
998 |
+ |
viewflags |= VWORTHO; |
999 |
|
} |
1000 |
|
|
1001 |
|
|
1002 |
< |
static |
1003 |
< |
wipeclean() /* prepare for redraw */ |
1002 |
> |
static void |
1003 |
> |
wipeclean(void) /* prepare for redraw */ |
1004 |
|
{ |
1005 |
< |
/* clear depth buffer */ |
1005 |
> |
glDrawBuffer(GL_BACK); /* use double-buffer mode */ |
1006 |
> |
glReadBuffer(GL_BACK); |
1007 |
> |
/* clear buffers */ |
1008 |
|
#ifdef STEREO |
1009 |
|
setstereobuf(STEREO_BUFFER_RIGHT); |
1010 |
< |
glClear(GL_DEPTH_BUFFER_BIT); |
1010 |
> |
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); |
1011 |
|
setstereobuf(STEREO_BUFFER_LEFT); |
1012 |
|
#endif |
1013 |
< |
glClear(GL_DEPTH_BUFFER_BIT); |
942 |
< |
if (viewsteady) /* clear samples if steady */ |
943 |
< |
odClean(); |
1013 |
> |
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); |
1014 |
|
freedepth(); |
1015 |
< |
setglpersp(&odev.v); /* reset view & clipping planes */ |
1015 |
> |
if ((viewflags&(VWCHANGE|VWSTEADY)) == |
1016 |
> |
(VWCHANGE|VWSTEADY)) { /* clear samples if new */ |
1017 |
> |
odClean(); |
1018 |
> |
viewflags &= ~VWCHANGE; /* change noted */ |
1019 |
> |
} else if (viewflags & VWSTEADY) |
1020 |
> |
odRedrawAll(); |
1021 |
> |
setglpersp(); /* reset view & clipping planes */ |
1022 |
|
} |
1023 |
|
|
1024 |
|
|
1025 |
< |
static |
1026 |
< |
getkey(ekey) /* get input key */ |
1027 |
< |
register XKeyPressedEvent *ekey; |
1025 |
> |
static void |
1026 |
> |
getkey( /* get input key */ |
1027 |
> |
register XKeyPressedEvent *ekey |
1028 |
> |
) |
1029 |
|
{ |
1030 |
|
Window rootw, childw; |
1031 |
|
int rootx, rooty, wx, wy; |
1038 |
|
return; |
1039 |
|
switch (buf[0]) { |
1040 |
|
case 'h': /* turn on height motion lock */ |
1041 |
< |
headlocked = 1; |
1041 |
> |
viewflags |= VWHEADLOCK; |
1042 |
|
return; |
1043 |
|
case 'H': /* turn off height motion lock */ |
1044 |
< |
headlocked = 0; |
1044 |
> |
viewflags &= ~VWHEADLOCK; |
1045 |
|
return; |
1046 |
|
case 'l': /* retrieve last view */ |
1047 |
|
inpresflags |= DFL(DC_LASTVIEW); |
1069 |
|
inpresflags |= DFL(DC_RESUME); |
1070 |
|
return; |
1071 |
|
case CTRL('R'): /* redraw screen */ |
1072 |
< |
odRemap(0); |
1073 |
< |
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); |
1072 |
> |
odRemap(0); /* new tone mapping */ |
1073 |
> |
glClear(GL_DEPTH_BUFFER_BIT); |
1074 |
|
#ifdef STEREO |
1075 |
|
setstereobuf(STEREO_BUFFER_RIGHT); |
1076 |
< |
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); |
1076 |
> |
glClear(GL_DEPTH_BUFFER_BIT); |
1077 |
|
setstereobuf(STEREO_BUFFER_LEFT); |
1078 |
|
#endif |
1079 |
|
return; |
1080 |
|
case CTRL('L'): /* refresh from server */ |
1081 |
|
if (inpresflags & DFL(DC_REDRAW)) |
1082 |
< |
return; |
1082 |
> |
return; /* already called */ |
1083 |
|
XRaiseWindow(ourdisplay, gwind); |
1084 |
< |
XFlush(ourdisplay); |
1085 |
< |
sleep(1); |
1086 |
< |
wipeclean(); /* fresh display */ |
1087 |
< |
odRemap(1); /* fresh tone mapping */ |
1011 |
< |
dev_flush(); /* draw octrees */ |
1084 |
> |
XFlush(ourdisplay); /* raise up window */ |
1085 |
> |
sleep(1); /* wait for restacking */ |
1086 |
> |
dev_clear(); /* clear buffer and samples */ |
1087 |
> |
odRemap(1); /* start fresh histogram */ |
1088 |
|
inpresflags |= DFL(DC_REDRAW); /* resend values from server */ |
1013 |
– |
rayqleft = 0; /* hold off update */ |
1089 |
|
return; |
1090 |
|
case 'K': /* kill rtrace process(es) */ |
1091 |
|
inpresflags |= DFL(DC_KILL); |
1106 |
|
} |
1107 |
|
|
1108 |
|
|
1109 |
< |
static |
1110 |
< |
fixwindow(eexp) /* repair damage to window */ |
1111 |
< |
register XExposeEvent *eexp; |
1109 |
> |
static void |
1110 |
> |
fixwindow( /* repair damage to window */ |
1111 |
> |
register XExposeEvent *eexp |
1112 |
> |
) |
1113 |
|
{ |
1114 |
|
int xmin, ymin, xmax, ymax; |
1115 |
|
|
1116 |
< |
if (odev.hres == 0 | odev.vres == 0) { /* first exposure */ |
1116 |
> |
if ((odev.hres == 0) | (odev.vres == 0)) { /* first exposure */ |
1117 |
|
resizewindow((XConfigureEvent *)eexp); |
1118 |
|
return; |
1119 |
|
} |
1120 |
|
xmin = eexp->x; xmax = eexp->x + eexp->width; |
1121 |
|
ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y; |
1122 |
+ |
|
1123 |
+ |
if (xmin <= 0 && xmax >= odev.hres-1 && |
1124 |
+ |
ymin <= 0 && ymax >= odev.vres) { |
1125 |
+ |
DCHECK(eexp->count, WARNING, "multiple clear in fixwindow"); |
1126 |
+ |
wipeclean(); /* make sure we're go */ |
1127 |
+ |
return; |
1128 |
+ |
} |
1129 |
|
/* clear portion of depth */ |
1130 |
|
glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); |
1131 |
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
1152 |
|
} |
1153 |
|
|
1154 |
|
|
1155 |
< |
static |
1156 |
< |
resizewindow(ersz) /* resize window */ |
1157 |
< |
register XConfigureEvent *ersz; |
1155 |
> |
static void |
1156 |
> |
resizewindow( /* resize window */ |
1157 |
> |
register XConfigureEvent *ersz |
1158 |
> |
) |
1159 |
|
{ |
1160 |
|
glViewport(0, 0, ersz->width, ersz->height); |
1161 |
|
|
1169 |
|
odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres); |
1170 |
|
|
1171 |
|
inpresflags |= DFL(DC_SETVIEW); |
1172 |
+ |
viewflags |= VWCHANGE; |
1173 |
|
} |