ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhd_glx.c
Revision: 3.14
Committed: Tue Jan 6 05:26:19 1998 UTC (26 years, 4 months ago) by gregl
Content type: text/plain
Branch: MAIN
Changes since 3.13: +8 -0 lines
Log Message:
created dev_clear() routine to clear device ray cache

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 dev_clear() /* clear our quadtree */
199 {
200 qtCompost(100);
201 glClear(GL_DEPTH_BUFFER_BIT);
202 rayqleft = 0; /* hold off update */
203 }
204
205
206 int
207 dev_view(nv) /* assign new driver view */
208 register VIEW *nv;
209 {
210 if (nv->type == VT_PAR || /* check view legality */
211 nv->horiz > 160. || nv->vert > 160.) {
212 error(COMMAND, "illegal view type/angle");
213 nv->type = odev.v.type;
214 nv->horiz = odev.v.horiz;
215 nv->vert = odev.v.vert;
216 return(0);
217 }
218 if (nv->vfore > FTINY) {
219 error(COMMAND, "cannot handle fore clipping");
220 nv->vfore = 0.;
221 return(0);
222 }
223 if (nv != &odev.v) {
224 if (!FEQ(nv->horiz,odev.v.horiz) || /* resize window? */
225 !FEQ(nv->vert,odev.v.vert)) {
226 int dw = DisplayWidth(ourdisplay,ourscreen);
227 int dh = DisplayHeight(ourdisplay,ourscreen);
228
229 dw -= 25; /* for window frame */
230 dh -= 50;
231 odev.hres = 2.*VIEWDIST/pwidth *
232 tan(PI/180./2.*nv->horiz);
233 odev.vres = 2.*VIEWDIST/pheight *
234 tan(PI/180./2.*nv->vert);
235 if (odev.hres > dw) {
236 odev.vres = dw * odev.vres / odev.hres;
237 odev.hres = dw;
238 }
239 if (odev.vres > dh) {
240 odev.hres = dh * odev.hres / odev.vres;
241 odev.vres = dh;
242 }
243 XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres);
244 dev_input(); /* get resize event */
245 }
246 copystruct(&odev.v, nv);
247 }
248 if (nxtzmax > FTINY) {
249 curzmax = nxtzmax;
250 nxtzmax = 0.;
251 }
252 glClear(GL_DEPTH_BUFFER_BIT);
253 qtReplant();
254 return(1);
255 }
256
257
258 int
259 dev_input() /* get X11 input */
260 {
261 inpresflags = 0;
262
263 do
264 getevent();
265
266 while (XQLength(ourdisplay) > 0);
267
268 return(inpresflags);
269 }
270
271
272 int
273 dev_flush() /* flush output */
274 {
275 qtUpdate();
276 glFlush();
277 rayqleft = RAYQLEN;
278 return(XPending(ourdisplay));
279 }
280
281
282 dev_cone(rgb, ip, rad) /* render a cone in view coordinates */
283 BYTE rgb[3];
284 FVECT ip;
285 double rad;
286 {
287 register int ci, j;
288 double apexh, basez;
289 /* is window mapped? */
290 if (!mapped)
291 return;
292 /* compute apex height (0. to 1.) */
293 if (ip[2] > 1e6)
294 apexh = 1. - 1./DEPTHFACT;
295 else {
296 if (ip[2] > nxtzmax)
297 nxtzmax = ip[2];
298 if (ip[2] >= curzmax)
299 apexh = 1. - 1./DEPTHFACT;
300 else
301 apexh = 1. - ip[2]/(curzmax*DEPTHFACT);
302 }
303 rad *= 1.25; /* find conservative cone match */
304 for (ci = 0; ci < MAXCONE-1; ci++)
305 if (cone[ci].rad >= rad)
306 break;
307 /* draw it */
308 glColor3ub(rgb[0], rgb[1], rgb[2]);
309 glBegin(GL_TRIANGLE_FAN);
310 glVertex3d(ip[0], ip[1], apexh); /* start with apex */
311 basez = apexh*cone[ci].va[0][2]; /* base z's all the same */
312 for (j = 0; j < cone[ci].nverts; j++) /* draw each face */
313 glVertex3d(ip[0]+cone[ci].va[j][0], ip[1]+cone[ci].va[j][1],
314 basez);
315 /* connect last to first */
316 glVertex3d(ip[0]+cone[ci].va[0][0], ip[1]+cone[ci].va[0][1], basez);
317 glEnd(); /* all done */
318 }
319
320
321 static int
322 mytmflags() /* figure out tone mapping flags */
323 {
324 extern char *progname;
325 register char *cp, *tail;
326 /* find basic name */
327 for (cp = tail = progname; *cp; cp++)
328 if (*cp == '/')
329 tail = cp+1;
330 for (cp = tail; *cp && *cp != '.'; cp++)
331 ;
332 if (cp-tail == 3 && !strncmp(tail, "glx", 3))
333 return(TM_F_CAMERA|TM_F_NOSTDERR);
334 if (cp-tail == 4 && !strncmp(tail, "glxh", 4))
335 return(TM_F_HUMAN|TM_F_NOSTDERR);
336 error(USER, "illegal driver name");
337 }
338
339
340 static
341 initcones() /* initialize cone vertices */
342 {
343 register int i, j;
344 double minrad, d;
345
346 if (cone[0].nverts)
347 freecones();
348 minrad = 2.*qtMinNodesiz/(double)(DisplayWidth(ourdisplay,ourscreen) +
349 DisplayHeight(ourdisplay,ourscreen));
350 for (i = 0; i < MAXCONE; i++) {
351 d = (double)i/(MAXCONE-1); d *= d; /* x^2 distribution */
352 cone[i].rad = minrad + (1.-minrad)*d;
353 cone[i].nverts = MINVERT + (MAXVERT-MINVERT)*d;
354 cone[i].va = (FVECT *)malloc(cone[i].nverts*sizeof(FVECT));
355 if (cone[i].va == NULL)
356 error(SYSTEM, "out of memory in initcones");
357 for (j = cone[i].nverts; j--; ) {
358 d = 2.*PI * (j+.5) / (cone[i].nverts);
359 cone[i].va[j][0] = cos(d) * cone[i].rad;
360 cone[i].va[j][1] = sin(d) * cone[i].rad;
361 cone[i].va[j][2] = 1. - cone[i].rad;
362 }
363 }
364 }
365
366
367 static
368 freecones() /* free cone vertices */
369 {
370 register int i;
371
372 for (i = MAXCONE; i--; )
373 if (cone[i].nverts) {
374 free((char *)cone[i].va);
375 cone[i].va = NULL;
376 cone[i].nverts = 0;
377 }
378 }
379
380
381 static
382 getevent() /* get next event */
383 {
384 XNextEvent(ourdisplay, levptr(XEvent));
385 switch (levptr(XEvent)->type) {
386 case ConfigureNotify:
387 resizewindow(levptr(XConfigureEvent));
388 break;
389 case UnmapNotify:
390 mapped = 0;
391 break;
392 case MapNotify:
393 mapped = 1;
394 break;
395 case Expose:
396 fixwindow(levptr(XExposeEvent));
397 break;
398 case KeyPress:
399 getkey(levptr(XKeyPressedEvent));
400 break;
401 case ButtonPress:
402 getmove(levptr(XButtonPressedEvent));
403 break;
404 }
405 }
406
407
408 static
409 draw3dline(wp) /* draw 3d line in world coordinates */
410 register FVECT wp[2];
411 {
412 glVertex3d(wp[0][0], wp[0][1], wp[0][2]);
413 glVertex3d(wp[1][0], wp[1][1], wp[1][2]);
414 }
415
416
417 static
418 draw_grids() /* draw holodeck section grids */
419 {
420 static BYTE gridrgba[4] = {0x0, 0xff, 0xff, 0x00};
421 double xmin, xmax, ymin, ymax, zmin, zmax;
422 double d, cx, sx, crad;
423 FVECT vx, vy;
424 register int i, j;
425 /* can we even do it? */
426 if (!mapped || odev.v.type != VT_PER)
427 return;
428 /* compute view frustum */
429 if (normalize(odev.v.vdir) == 0.0)
430 return;
431 zmin = 0.01;
432 zmax = 10000.;
433 if (odev.v.vfore > FTINY)
434 zmin = odev.v.vfore;
435 if (odev.v.vaft > FTINY)
436 zmax = odev.v.vaft;
437 xmax = zmin * tan(PI/180./2. * odev.v.horiz);
438 xmin = -xmax;
439 d = odev.v.hoff * (xmax - xmin);
440 xmin += d; xmax += d;
441 ymax = zmin * tan(PI/180./2. * odev.v.vert);
442 ymin = -ymax;
443 d = odev.v.voff * (ymax - ymin);
444 ymin += d; ymax += d;
445 /* set view matrix */
446 glMatrixMode(GL_PROJECTION);
447 glPushMatrix();
448 glLoadIdentity();
449 glFrustum(xmin, xmax, ymin, ymax, zmin, zmax);
450 gluLookAt(odev.v.vp[0], odev.v.vp[1], odev.v.vp[2],
451 odev.v.vp[0] + odev.v.vdir[0],
452 odev.v.vp[1] + odev.v.vdir[1],
453 odev.v.vp[2] + odev.v.vdir[2],
454 odev.v.vup[0], odev.v.vup[1], odev.v.vup[2]);
455 glDisable(GL_DEPTH_TEST); /* write no depth values */
456 glColor4ub(gridrgba[0], gridrgba[1], gridrgba[2], gridrgba[3]);
457 glBegin(GL_LINES); /* draw each grid line */
458 gridlines(draw3dline);
459 glEnd();
460 glEnable(GL_DEPTH_TEST); /* restore rendering params */
461 glPopMatrix();
462 }
463
464
465 static
466 moveview(dx, dy, mov, orb) /* move our view */
467 int dx, dy, mov, orb;
468 {
469 VIEW nv;
470 FVECT odir, v1;
471 double d;
472 register int li;
473 /* start with old view */
474 copystruct(&nv, &odev.v);
475 /* change view direction */
476 if (mov | orb) {
477 if ((li = qtFindLeaf(dx, dy)) < 0)
478 return(0); /* not on window */
479 VSUM(odir, qtL.wp[li], nv.vp, -1.);
480 } else {
481 if (viewray(nv.vp, nv.vdir, &odev.v,
482 (dx+.5)/odev.hres, (dy+.5)/odev.vres) < -FTINY)
483 return(0); /* outside view */
484 }
485 if (orb && mov) { /* orbit left/right */
486 spinvector(odir, odir, nv.vup, d=MOVDEG*PI/180.*mov);
487 VSUM(nv.vp, qtL.wp[li], odir, -1.);
488 spinvector(nv.vdir, nv.vdir, nv.vup, d);
489 } else if (orb) { /* orbit up/down */
490 fcross(v1, odir, nv.vup);
491 if (normalize(v1) == 0.)
492 return(0);
493 spinvector(odir, odir, v1, d=MOVDEG*PI/180.*orb);
494 VSUM(nv.vp, qtL.wp[li], odir, -1.);
495 spinvector(nv.vdir, nv.vdir, v1, d);
496 } else if (mov) { /* move forward/backward */
497 d = MOVPCT/100. * mov;
498 VSUM(nv.vp, nv.vp, odir, d);
499 }
500 if (!mov ^ !orb && headlocked) { /* restore head height */
501 VSUM(v1, odev.v.vp, nv.vp, -1.);
502 d = DOT(v1, odev.v.vup);
503 VSUM(nv.vp, nv.vp, odev.v.vup, d);
504 }
505 if (setview(&nv) != NULL)
506 return(0); /* illegal view */
507 dev_view(&nv);
508 inpresflags |= DFL(DC_SETVIEW);
509 return(1);
510 }
511
512
513 static
514 getmove(ebut) /* get view change */
515 XButtonPressedEvent *ebut;
516 {
517 int movdir = MOVDIR(ebut->button);
518 int movorb = MOVORB(ebut->state);
519 int oldnodesiz = qtMinNodesiz;
520 Window rootw, childw;
521 int rootx, rooty, wx, wy;
522 unsigned int statemask;
523
524 qtMinNodesiz = 24; /* accelerate update rate */
525 XNoOp(ourdisplay);
526
527 while (!XCheckMaskEvent(ourdisplay,
528 ButtonReleaseMask, levptr(XEvent))) {
529
530 if (!XQueryPointer(ourdisplay, gwind, &rootw, &childw,
531 &rootx, &rooty, &wx, &wy, &statemask))
532 break; /* on another screen */
533
534 if (!moveview(wx, odev.vres-1-wy, movdir, movorb)) {
535 sleep(1);
536 continue;
537 }
538 glClear(GL_COLOR_BUFFER_BIT);
539 qtUpdate();
540 draw_grids();
541 glFlush();
542 }
543 if (!(inpresflags & DFL(DC_SETVIEW))) { /* do final motion */
544 movdir = MOVDIR(levptr(XButtonReleasedEvent)->button);
545 wx = levptr(XButtonReleasedEvent)->x;
546 wy = levptr(XButtonReleasedEvent)->y;
547 moveview(wx, odev.vres-1-wy, movdir, movorb);
548 }
549 dev_flush();
550
551 qtMinNodesiz = oldnodesiz; /* restore quadtree resolution */
552 }
553
554
555 static
556 getkey(ekey) /* get input key */
557 register XKeyPressedEvent *ekey;
558 {
559 int n;
560 char buf[8];
561
562 n = XLookupString(ekey, buf, sizeof(buf), NULL, NULL);
563 if (n != 1)
564 return;
565 switch (buf[0]) {
566 case 'h': /* turn on height motion lock */
567 headlocked = 1;
568 return;
569 case 'H': /* turn off height motion lock */
570 headlocked = 0;
571 return;
572 case 'l': /* retrieve last view */
573 inpresflags |= DFL(DC_LASTVIEW);
574 return;
575 case 'p': /* pause computation */
576 inpresflags |= DFL(DC_PAUSE);
577 return;
578 case 'v': /* spit out view */
579 inpresflags |= DFL(DC_GETVIEW);
580 return;
581 case '\n':
582 case '\r': /* resume computation */
583 inpresflags |= DFL(DC_RESUME);
584 return;
585 case CTRL('R'): /* redraw screen */
586 if (nxtzmax > FTINY) {
587 curzmax = nxtzmax;
588 nxtzmax = 0.;
589 }
590 glClear(GL_DEPTH_BUFFER_BIT);
591 qtRedraw(0, 0, odev.hres, odev.vres);
592 return;
593 case CTRL('L'): /* refresh from server */
594 if (inpresflags & DFL(DC_REDRAW))
595 return;
596 if (nxtzmax > FTINY) {
597 curzmax = nxtzmax;
598 nxtzmax = 0.;
599 }
600 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
601 draw_grids();
602 glFlush();
603 qtCompost(100); /* get rid of old values */
604 inpresflags |= DFL(DC_REDRAW); /* resend values from server */
605 rayqleft = 0; /* hold off update */
606 return;
607 case 'K': /* kill rtrace process(es) */
608 inpresflags |= DFL(DC_KILL);
609 break;
610 case 'R': /* restart rtrace */
611 inpresflags |= DFL(DC_RESTART);
612 break;
613 case 'C': /* clobber holodeck */
614 inpresflags |= DFL(DC_CLOBBER);
615 break;
616 case 'q': /* quit the program */
617 inpresflags |= DFL(DC_QUIT);
618 return;
619 default:
620 XBell(ourdisplay, 0);
621 return;
622 }
623 }
624
625
626 static
627 fixwindow(eexp) /* repair damage to window */
628 register XExposeEvent *eexp;
629 {
630 int xmin, xmax, ymin, ymax;
631
632 if (odev.hres == 0 || odev.vres == 0) /* first exposure */
633 resizewindow((XConfigureEvent *)eexp);
634 xmin = eexp->x; xmax = eexp->x + eexp->width;
635 ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y;
636 /* clear portion of depth */
637 glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
638 glDepthFunc(GL_ALWAYS);
639 glBegin(GL_POLYGON);
640 glVertex3d((double)xmin/odev.hres, (double)ymin/odev.vres, 0.);
641 glVertex3d((double)xmax/odev.hres, (double)ymin/odev.vres, 0.);
642 glVertex3d((double)xmax/odev.hres, (double)ymax/odev.vres, 0.);
643 glVertex3d((double)xmin/odev.hres, (double)ymax/odev.vres, 0.);
644 glEnd();
645 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
646 glDepthFunc(GL_LEQUAL);
647 qtRedraw(xmin, ymin, xmax, ymax);
648 }
649
650
651 static
652 resizewindow(ersz) /* resize window */
653 register XConfigureEvent *ersz;
654 {
655 glViewport(0, 0, ersz->width, ersz->height);
656
657 if (ersz->width == odev.hres && ersz->height == odev.vres)
658 return;
659
660 odev.hres = ersz->width;
661 odev.vres = ersz->height;
662
663 odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres);
664 odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres);
665
666 inpresflags |= DFL(DC_SETVIEW);
667 }