ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_glx.c
Revision: 3.12
Committed: Thu Jan 1 16:28:44 1998 UTC (26 years, 3 months ago) by gregl
Content type: text/plain
Branch: MAIN
Changes since 3.11: +3 -0 lines
Log Message:
added missing test for unmapped window in dev_cone()

File Contents

# Content
1 /* Copyright (c) 1997 Silicon Graphics, Inc. */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ SGI";
5 #endif
6
7 /*
8 * OpenGL GLX driver for holodeck display.
9 * Based on x11 driver.
10 */
11
12 #include "standard.h"
13 #include "rhd_qtree.h"
14
15 #include <GL/glx.h>
16
17 #include "x11icon.h"
18
19 #ifndef RAYQLEN
20 #define RAYQLEN 50000 /* max. rays to queue before flush */
21 #endif
22
23 #ifndef FEQ
24 #define FEQ(a,b) ((a)-(b) <= FTINY && (a)-(b) >= -FTINY)
25 #endif
26
27 #ifndef MAXCONE
28 #define MAXCONE 16 /* number of different cone sizes */
29 #endif
30 #ifndef MAXVERT
31 #define MAXVERT 32 /* maximum number of cone vertices */
32 #endif
33 #ifndef MINVERT
34 #define MINVERT 4 /* minimum number of cone vertices */
35 #endif
36 #ifndef DEPTHFACT
37 #define DEPTHFACT 16. /* multiplier for depth tests */
38 #endif
39
40 #define GAMMA 1.4 /* default gamma correction */
41
42 #define MOVPCT 7 /* percent distance to move /frame */
43 #define MOVDIR(b) ((b)==Button1 ? 1 : (b)==Button2 ? 0 : -1)
44 #define MOVDEG (-5) /* degrees to orbit CW/down /frame */
45 #define MOVORB(s) ((s)&ShiftMask ? 1 : (s)&ControlMask ? -1 : 0)
46
47 #define MINWIDTH 480 /* minimum graphics window width */
48 #define MINHEIGHT 400 /* minimum graphics window height */
49
50 #define VIEWDIST 356 /* assumed viewing distance (mm) */
51
52 #define BORWIDTH 5 /* border width */
53
54 #define ourscreen DefaultScreen(ourdisplay)
55 #define ourroot RootWindow(ourdisplay,ourscreen)
56 #define ourmask (StructureNotifyMask|ExposureMask|KeyPressMask|\
57 ButtonPressMask|ButtonReleaseMask)
58
59 #define levptr(etype) ((etype *)&currentevent)
60
61 struct driver odev; /* global device driver structure */
62
63 static XEvent currentevent; /* current event */
64
65 static int mapped = 0; /* window is mapped? */
66 static unsigned long ourblack=0, ourwhite=~0;
67
68 static Display *ourdisplay = NULL; /* our display */
69 static XVisualInfo *ourvinf; /* our visual information */
70 static Window gwind = 0; /* our graphics window */
71 static GLXContext gctx; /* our GLX context */
72
73 static double pwidth, pheight; /* pixel dimensions (mm) */
74
75 static double curzmax = 1e4; /* current depth upper limit */
76 static double nxtzmax = 0.; /* maximum (finite) depth so far */
77
78 static struct {
79 double rad; /* cone radius */
80 int nverts; /* number of vertices */
81 FVECT *va; /* allocated vertex array */
82 } cone[MAXCONE]; /* precomputed cones for drawing */
83
84 static int inpresflags; /* input result flags */
85
86 static int headlocked = 0; /* lock vertical motion */
87
88 static int resizewindow(), getevent(), getkey(), moveview(),
89 initcones(), freecones(),
90 getmove(), fixwindow(), mytmflags();
91
92
93 dev_open(id) /* initialize X11 driver */
94 char *id;
95 {
96 extern char *getenv();
97 static int atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8,
98 GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8,
99 GLX_DEPTH_SIZE,15, None};
100 char *gv;
101 double gamval = GAMMA;
102 XSetWindowAttributes ourwinattr;
103 XWMHints ourxwmhints;
104 XSizeHints oursizhints;
105 /* set quadtree globals */
106 qtMinNodesiz = 3;
107 qtDepthEps = 0.07;
108 /* open display server */
109 ourdisplay = XOpenDisplay(NULL);
110 if (ourdisplay == NULL)
111 error(USER, "cannot open X-windows; DISPLAY variable set?\n");
112 /* find a usable visual */
113 ourvinf = glXChooseVisual(ourdisplay, ourscreen, atlBest);
114 if (ourvinf == NULL)
115 error(USER, "no suitable visuals available");
116 /* get a context */
117 gctx = glXCreateContext(ourdisplay, ourvinf, NULL, GL_TRUE);
118 /* set gamma and tone mapping */
119 if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL
120 || (gv = getenv("DISPLAY_GAMMA")) != NULL)
121 gamval = atof(gv);
122 if (tmInit(mytmflags(), stdprims, gamval) == NULL)
123 error(SYSTEM, "not enough memory in dev_open");
124 /* open window */
125 ourwinattr.background_pixel = ourblack;
126 ourwinattr.border_pixel = ourblack;
127 ourwinattr.event_mask = ourmask;
128 /* this is stupid */
129 ourwinattr.colormap = XCreateColormap(ourdisplay, ourroot,
130 ourvinf->visual, AllocNone);
131 gwind = XCreateWindow(ourdisplay, ourroot, 0, 0,
132 DisplayWidth(ourdisplay,ourscreen)-2*BORWIDTH,
133 DisplayHeight(ourdisplay,ourscreen)-2*BORWIDTH,
134 BORWIDTH, ourvinf->depth, InputOutput, ourvinf->visual,
135 CWBackPixel|CWBorderPixel|CWColormap|CWEventMask, &ourwinattr);
136 if (gwind == 0)
137 error(SYSTEM, "cannot create window\n");
138 XStoreName(ourdisplay, gwind, id);
139 /* set window manager hints */
140 ourxwmhints.flags = InputHint|IconPixmapHint;
141 ourxwmhints.input = True;
142 ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay,
143 gwind, x11icon_bits, x11icon_width, x11icon_height);
144 XSetWMHints(ourdisplay, gwind, &ourxwmhints);
145 oursizhints.min_width = MINWIDTH;
146 oursizhints.min_height = MINHEIGHT;
147 oursizhints.flags = PMinSize;
148 XSetNormalHints(ourdisplay, gwind, &oursizhints);
149 /* set GLX context */
150 glXMakeCurrent(ourdisplay, gwind, gctx);
151 glEnable(GL_DEPTH_TEST);
152 glDepthFunc(GL_LEQUAL);
153 glShadeModel(GL_FLAT);
154 glDisable(GL_DITHER);
155 glDisable(GL_CULL_FACE);
156 glMatrixMode(GL_PROJECTION);
157 glOrtho(0., 1., 0., 1., -.01, 1.01);
158 glTranslated(0., 0., -1.01);
159 /* figure out sensible view */
160 pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) /
161 DisplayWidth(ourdisplay, ourscreen);
162 pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) /
163 DisplayHeight(ourdisplay, ourscreen);
164 copystruct(&odev.v, &stdview);
165 odev.v.type = VT_PER;
166 /* map the window */
167 XMapWindow(ourdisplay, gwind);
168 dev_input(); /* sets size and view angles */
169 /* allocate our leaf pile */
170 if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) *
171 DisplayHeight(ourdisplay,ourscreen) * 3 /
172 (qtMinNodesiz*qtMinNodesiz*2)))
173 error(SYSTEM, "insufficient memory for value storage");
174 odev.name = id;
175 odev.ifd = ConnectionNumber(ourdisplay);
176 /* initialize cone array */
177 initcones();
178 }
179
180
181 dev_close() /* close our display and free resources */
182 {
183 glXMakeCurrent(ourdisplay, None, NULL);
184 glXDestroyContext(ourdisplay, gctx);
185 XDestroyWindow(ourdisplay, gwind);
186 gwind = 0;
187 XCloseDisplay(ourdisplay);
188 ourdisplay = NULL;
189 qtFreeLeaves();
190 tmDone(NULL);
191 freecones();
192 odev.v.type = 0;
193 odev.hres = odev.vres = 0;
194 odev.ifd = -1;
195 }
196
197
198 int
199 dev_view(nv) /* assign new driver view */
200 register VIEW *nv;
201 {
202 if (nv->type == VT_PAR || /* check view legality */
203 nv->horiz > 160. || nv->vert > 160.) {
204 error(COMMAND, "illegal view type/angle");
205 nv->type = odev.v.type;
206 nv->horiz = odev.v.horiz;
207 nv->vert = odev.v.vert;
208 return(0);
209 }
210 if (nv->vfore > FTINY) {
211 error(COMMAND, "cannot handle fore clipping");
212 nv->vfore = 0.;
213 return(0);
214 }
215 if (nv != &odev.v) {
216 if (!FEQ(nv->horiz,odev.v.horiz) || /* resize window? */
217 !FEQ(nv->vert,odev.v.vert)) {
218 int dw = DisplayWidth(ourdisplay,ourscreen);
219 int dh = DisplayHeight(ourdisplay,ourscreen);
220
221 dw -= 25; /* for window frame */
222 dh -= 50;
223 odev.hres = 2.*VIEWDIST/pwidth *
224 tan(PI/180./2.*nv->horiz);
225 odev.vres = 2.*VIEWDIST/pheight *
226 tan(PI/180./2.*nv->vert);
227 if (odev.hres > dw) {
228 odev.vres = dw * odev.vres / odev.hres;
229 odev.hres = dw;
230 }
231 if (odev.vres > dh) {
232 odev.hres = dh * odev.hres / odev.vres;
233 odev.vres = dh;
234 }
235 XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres);
236 dev_input(); /* get resize event */
237 }
238 copystruct(&odev.v, nv);
239 }
240 if (nxtzmax > FTINY) {
241 curzmax = nxtzmax;
242 nxtzmax = 0.;
243 }
244 glClear(GL_DEPTH_BUFFER_BIT);
245 qtReplant();
246 return(1);
247 }
248
249
250 int
251 dev_input() /* get X11 input */
252 {
253 inpresflags = 0;
254
255 do
256 getevent();
257
258 while (XQLength(ourdisplay) > 0);
259
260 return(inpresflags);
261 }
262
263
264 int
265 dev_flush() /* flush output */
266 {
267 qtUpdate();
268 glFlush();
269 rayqleft = RAYQLEN;
270 return(XPending(ourdisplay));
271 }
272
273
274 dev_cone(rgb, ip, rad) /* render a cone in view coordinates */
275 BYTE rgb[3];
276 FVECT ip;
277 double rad;
278 {
279 register int ci, j;
280 double apexh, basez;
281 /* is window mapped? */
282 if (!mapped)
283 return;
284 /* compute apex height (0. to 1.) */
285 if (ip[2] > 1e6)
286 apexh = 1. - 1./DEPTHFACT;
287 else {
288 if (ip[2] > nxtzmax)
289 nxtzmax = ip[2];
290 if (ip[2] >= curzmax)
291 apexh = 1. - 1./DEPTHFACT;
292 else
293 apexh = 1. - ip[2]/(curzmax*DEPTHFACT);
294 }
295 rad *= 1.25; /* find conservative cone match */
296 for (ci = 0; ci < MAXCONE-1; ci++)
297 if (cone[ci].rad >= rad)
298 break;
299 /* draw it */
300 glColor3ub(rgb[0], rgb[1], rgb[2]);
301 glBegin(GL_TRIANGLE_FAN);
302 glVertex3d(ip[0], ip[1], apexh); /* start with apex */
303 basez = apexh*cone[ci].va[0][2]; /* base z's all the same */
304 for (j = 0; j < cone[ci].nverts; j++) /* draw each face */
305 glVertex3d(ip[0]+cone[ci].va[j][0], ip[1]+cone[ci].va[j][1],
306 basez);
307 /* connect last to first */
308 glVertex3d(ip[0]+cone[ci].va[0][0], ip[1]+cone[ci].va[0][1], basez);
309 glEnd(); /* all done */
310 }
311
312
313 static int
314 mytmflags() /* figure out tone mapping flags */
315 {
316 extern char *progname;
317 register char *cp, *tail;
318 /* find basic name */
319 for (cp = tail = progname; *cp; cp++)
320 if (*cp == '/')
321 tail = cp+1;
322 for (cp = tail; *cp && *cp != '.'; cp++)
323 ;
324 if (cp-tail == 3 && !strncmp(tail, "glx", 3))
325 return(TM_F_CAMERA|TM_F_NOSTDERR);
326 if (cp-tail == 4 && !strncmp(tail, "glxh", 4))
327 return(TM_F_HUMAN|TM_F_NOSTDERR);
328 error(USER, "illegal driver name");
329 }
330
331
332 static
333 initcones() /* initialize cone vertices */
334 {
335 register int i, j;
336 double minrad, d;
337
338 if (cone[0].nverts)
339 freecones();
340 minrad = 2.*qtMinNodesiz/(double)(DisplayWidth(ourdisplay,ourscreen) +
341 DisplayHeight(ourdisplay,ourscreen));
342 for (i = 0; i < MAXCONE; i++) {
343 d = (double)i/(MAXCONE-1); d *= d; /* x^2 distribution */
344 cone[i].rad = minrad + (1.-minrad)*d;
345 cone[i].nverts = MINVERT + (MAXVERT-MINVERT)*d;
346 cone[i].va = (FVECT *)malloc(cone[i].nverts*sizeof(FVECT));
347 if (cone[i].va == NULL)
348 error(SYSTEM, "out of memory in initcones");
349 for (j = cone[i].nverts; j--; ) {
350 d = 2.*PI * (j+.5) / (cone[i].nverts);
351 cone[i].va[j][0] = cos(d) * cone[i].rad;
352 cone[i].va[j][1] = sin(d) * cone[i].rad;
353 cone[i].va[j][2] = 1. - cone[i].rad;
354 }
355 }
356 }
357
358
359 static
360 freecones() /* free cone vertices */
361 {
362 register int i;
363
364 for (i = MAXCONE; i--; )
365 if (cone[i].nverts) {
366 free((char *)cone[i].va);
367 cone[i].va = NULL;
368 cone[i].nverts = 0;
369 }
370 }
371
372
373 static
374 getevent() /* get next event */
375 {
376 XNextEvent(ourdisplay, levptr(XEvent));
377 switch (levptr(XEvent)->type) {
378 case ConfigureNotify:
379 resizewindow(levptr(XConfigureEvent));
380 break;
381 case UnmapNotify:
382 mapped = 0;
383 break;
384 case MapNotify:
385 mapped = 1;
386 break;
387 case Expose:
388 fixwindow(levptr(XExposeEvent));
389 break;
390 case KeyPress:
391 getkey(levptr(XKeyPressedEvent));
392 break;
393 case ButtonPress:
394 getmove(levptr(XButtonPressedEvent));
395 break;
396 }
397 }
398
399
400 static
401 draw3dline(wp) /* draw 3d line in world coordinates */
402 register FVECT wp[2];
403 {
404 glVertex3d(wp[0][0], wp[0][1], wp[0][2]);
405 glVertex3d(wp[1][0], wp[1][1], wp[1][2]);
406 }
407
408
409 static
410 draw_grids() /* draw holodeck section grids */
411 {
412 static BYTE gridrgba[4] = {0x0, 0xff, 0xff, 0x00};
413 double xmin, xmax, ymin, ymax, zmin, zmax;
414 double d, cx, sx, crad;
415 FVECT vx, vy;
416 register int i, j;
417 /* can we even do it? */
418 if (!mapped || odev.v.type != VT_PER)
419 return;
420 /* compute view frustum */
421 if (normalize(odev.v.vdir) == 0.0)
422 return;
423 zmin = 0.01;
424 zmax = 10000.;
425 if (odev.v.vfore > FTINY)
426 zmin = odev.v.vfore;
427 if (odev.v.vaft > FTINY)
428 zmax = odev.v.vaft;
429 xmax = zmin * tan(PI/180./2. * odev.v.horiz);
430 xmin = -xmax;
431 d = odev.v.hoff * (xmax - xmin);
432 xmin += d; xmax += d;
433 ymax = zmin * tan(PI/180./2. * odev.v.vert);
434 ymin = -ymax;
435 d = odev.v.voff * (ymax - ymin);
436 ymin += d; ymax += d;
437 /* set view matrix */
438 glMatrixMode(GL_PROJECTION);
439 glPushMatrix();
440 glLoadIdentity();
441 glFrustum(xmin, xmax, ymin, ymax, zmin, zmax);
442 gluLookAt(odev.v.vp[0], odev.v.vp[1], odev.v.vp[2],
443 odev.v.vp[0] + odev.v.vdir[0],
444 odev.v.vp[1] + odev.v.vdir[1],
445 odev.v.vp[2] + odev.v.vdir[2],
446 odev.v.vup[0], odev.v.vup[1], odev.v.vup[2]);
447 glDisable(GL_DEPTH_TEST); /* write no depth values */
448 glColor4ub(gridrgba[0], gridrgba[1], gridrgba[2], gridrgba[3]);
449 glBegin(GL_LINES); /* draw each grid line */
450 gridlines(draw3dline);
451 glEnd();
452 glEnable(GL_DEPTH_TEST); /* restore rendering params */
453 glPopMatrix();
454 }
455
456
457 static
458 moveview(dx, dy, mov, orb) /* move our view */
459 int dx, dy, mov, orb;
460 {
461 VIEW nv;
462 FVECT odir, v1;
463 double d;
464 register int li;
465 /* start with old view */
466 copystruct(&nv, &odev.v);
467 /* change view direction */
468 if (mov | orb) {
469 if ((li = qtFindLeaf(dx, dy)) < 0)
470 return(0); /* not on window */
471 VSUM(odir, qtL.wp[li], nv.vp, -1.);
472 } else {
473 if (viewray(nv.vp, nv.vdir, &odev.v,
474 (dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY)
475 return(0); /* outside view */
476 }
477 if (orb && mov) { /* orbit left/right */
478 spinvector(odir, odir, nv.vup, d=MOVDEG*PI/180.*mov);
479 VSUM(nv.vp, qtL.wp[li], odir, -1.);
480 spinvector(nv.vdir, nv.vdir, nv.vup, d);
481 } else if (orb) { /* orbit up/down */
482 fcross(v1, odir, nv.vup);
483 if (normalize(v1) == 0.)
484 return(0);
485 spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb);
486 VSUM(nv.vp, qtL.wp[li], odir, -1.);
487 spinvector(nv.vdir, nv.vdir, v1, d);
488 } else if (mov) { /* move forward/backward */
489 d = MOVPCT/100. * mov;
490 VSUM(nv.vp, nv.vp, odir, d);
491 }
492 if (!mov ^ !orb && headlocked) { /* restore head height */
493 VSUM(v1, odev.v.vp, nv.vp, -1.);
494 d = DOT(v1, odev.v.vup);
495 VSUM(nv.vp, nv.vp, odev.v.vup, d);
496 }
497 if (setview(&nv) != NULL)
498 return(0); /* illegal view */
499 dev_view(&nv);
500 inpresflags |= DFL(DC_SETVIEW);
501 return(1);
502 }
503
504
505 static
506 getmove(ebut) /* get view change */
507 XButtonPressedEvent *ebut;
508 {
509 int movdir = MOVDIR(ebut->button);
510 int movorb = MOVORB(ebut->state);
511 int oldnodesiz = qtMinNodesiz;
512 Window rootw, childw;
513 int rootx, rooty, wx, wy;
514 unsigned int statemask;
515
516 qtMinNodesiz = 24; /* accelerate update rate */
517 XNoOp(ourdisplay);
518
519 while (!XCheckMaskEvent(ourdisplay,
520 ButtonReleaseMask, levptr(XEvent))) {
521
522 if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
523 &rootx, &rooty, &wx, &wy, &statemask))
524 break; /* on another screen */
525
526 if (!moveview(wx, odev.vres-1-wy, movdir, movorb)) {
527 sleep(1);
528 continue;
529 }
530 glClear(GL_COLOR_BUFFER_BIT);
531 qtUpdate();
532 draw_grids();
533 glFlush();
534 }
535 if (!(inpresflags & DFL(DC_SETVIEW))) { /* do final motion */
536 movdir = MOVDIR(levptr(XButtonReleasedEvent)->button);
537 wx = levptr(XButtonReleasedEvent)->x;
538 wy = levptr(XButtonReleasedEvent)->y;
539 moveview(wx, odev.vres-1-wy, movdir, movorb);
540 }
541 dev_flush();
542
543 qtMinNodesiz = oldnodesiz; /* restore quadtree resolution */
544 }
545
546
547 static
548 getkey(ekey) /* get input key */
549 register XKeyPressedEvent *ekey;
550 {
551 int n;
552 char buf[8];
553
554 n = XLookupString(ekey, buf, sizeof(buf), NULL, NULL);
555 if (n != 1)
556 return;
557 switch (buf[0]) {
558 case 'h': /* turn on height motion lock */
559 headlocked = 1;
560 return;
561 case 'H': /* turn off height motion lock */
562 headlocked = 0;
563 return;
564 case 'l': /* retrieve last view */
565 inpresflags |= DFL(DC_LASTVIEW);
566 return;
567 case 'p': /* pause computation */
568 inpresflags |= DFL(DC_PAUSE);
569 return;
570 case 'v': /* spit out view */
571 inpresflags |= DFL(DC_GETVIEW);
572 return;
573 case '\n':
574 case '\r': /* resume computation */
575 inpresflags |= DFL(DC_RESUME);
576 return;
577 case CTRL('R'): /* redraw screen */
578 if (nxtzmax > FTINY) {
579 curzmax = nxtzmax;
580 nxtzmax = 0.;
581 }
582 glClear(GL_DEPTH_BUFFER_BIT);
583 qtRedraw(0, 0, odev.hres, odev.vres);
584 return;
585 case CTRL('L'): /* refresh from server */
586 if (inpresflags & DFL(DC_REDRAW))
587 return;
588 if (nxtzmax > FTINY) {
589 curzmax = nxtzmax;
590 nxtzmax = 0.;
591 }
592 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
593 draw_grids();
594 glFlush();
595 qtCompost(100); /* get rid of old values */
596 inpresflags |= DFL(DC_REDRAW); /* resend values from server */
597 return;
598 case 'K': /* kill rtrace process(es) */
599 inpresflags |= DFL(DC_KILL);
600 break;
601 case 'R': /* restart rtrace */
602 inpresflags |= DFL(DC_RESTART);
603 break;
604 case 'C': /* clobber holodeck */
605 inpresflags |= DFL(DC_CLOBBER);
606 break;
607 case 'q': /* quit the program */
608 inpresflags |= DFL(DC_QUIT);
609 return;
610 default:
611 XBell(ourdisplay, 0);
612 return;
613 }
614 }
615
616
617 static
618 fixwindow(eexp) /* repair damage to window */
619 register XExposeEvent *eexp;
620 {
621 int xmin, xmax, ymin, ymax;
622
623 if (odev.hres == 0 || odev.vres == 0) /* first exposure */
624 resizewindow((XConfigureEvent *)eexp);
625 xmin = eexp->x; xmax = eexp->x + eexp->width;
626 ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y;
627 /* clear portion of depth */
628 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
629 glDepthFunc(GL_ALWAYS);
630 glBegin(GL_POLYGON);
631 glVertex3d((double)xmin/odev.hres, (double)ymin/odev.vres, 0.);
632 glVertex3d((double)xmax/odev.hres, (double)ymin/odev.vres, 0.);
633 glVertex3d((double)xmax/odev.hres, (double)ymax/odev.vres, 0.);
634 glVertex3d((double)xmin/odev.hres, (double)ymax/odev.vres, 0.);
635 glEnd();
636 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
637 glDepthFunc(GL_LEQUAL);
638 qtRedraw(xmin, ymin, xmax, ymax);
639 }
640
641
642 static
643 resizewindow(ersz) /* resize window */
644 register XConfigureEvent *ersz;
645 {
646 glViewport(0, 0, ersz->width, ersz->height);
647
648 if (ersz->width == odev.hres && ersz->height == odev.vres)
649 return;
650
651 odev.hres = ersz->width;
652 odev.vres = ersz->height;
653
654 odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres);
655 odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres);
656
657 inpresflags |= DFL(DC_SETVIEW);
658 }