| 1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
| 1 |
> |
/* Copyright (c) 1999 Silicon Graphics, Inc. */ |
| 2 |
|
|
| 3 |
|
#ifndef lint |
| 4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
| 22 |
|
|
| 23 |
|
#include "standard.h" |
| 24 |
|
|
| 25 |
– |
#include <sys/types.h> |
| 25 |
|
#include <GL/glx.h> |
| 26 |
|
#include <GL/glu.h> |
| 27 |
|
#ifdef STEREO |
| 36 |
|
#include "x11icon.h" |
| 37 |
|
|
| 38 |
|
#ifndef RAYQLEN |
| 39 |
< |
#define RAYQLEN 50000 /* 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()) |
| 95 |
|
|
| 96 |
|
static XEvent currentevent; /* current event */ |
| 97 |
|
|
| 100 |
– |
static int mapped = 0; /* window is mapped? */ |
| 98 |
|
static unsigned long ourblack=0, ourwhite=~0; |
| 99 |
|
|
| 100 |
|
static Display *ourdisplay = NULL; /* our display */ |
| 112 |
|
|
| 113 |
|
static int inpresflags; /* input result flags */ |
| 114 |
|
|
| 115 |
< |
static int headlocked; /* lock vertical motion */ |
| 115 |
> |
static int viewflags; /* what's happening with view */ |
| 116 |
|
|
| 120 |
– |
static int isperspective; /* perspective/ortho view */ |
| 121 |
– |
|
| 122 |
– |
static int viewsteady; /* is view steady? */ |
| 123 |
– |
|
| 117 |
|
static int resizewindow(), getevent(), getkey(), moveview(), wipeclean(), |
| 118 |
|
xferdepth(), freedepth(), setglortho(), |
| 119 |
|
setglpersp(), getframe(), getmove(), fixwindow(), mytmflags(); |
| 134 |
|
{ |
| 135 |
|
extern char *getenv(); |
| 136 |
|
static RGBPRIMS myprims = STDPRIMS; |
| 144 |
– |
#if (PORTALP<0) |
| 137 |
|
static int atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
| 138 |
|
GLX_RED_SIZE,8, GLX_GREEN_SIZE,8, |
| 139 |
|
GLX_BLUE_SIZE,8, GLX_DEPTH_SIZE,15, None}; |
| 140 |
|
static int atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
| 141 |
|
GLX_RED_SIZE,4, GLX_GREEN_SIZE,4, |
| 142 |
|
GLX_BLUE_SIZE,4, GLX_DEPTH_SIZE,15, None}; |
| 151 |
– |
#else |
| 152 |
– |
static int atlBest[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
| 153 |
– |
GLX_RED_SIZE,8, GLX_GREEN_SIZE,8, |
| 154 |
– |
GLX_BLUE_SIZE,8, GLX_ALPHA_SIZE,2, |
| 155 |
– |
GLX_DEPTH_SIZE,15, None}; |
| 156 |
– |
static int atlOK[] = {GLX_RGBA, GLX_DOUBLEBUFFER, |
| 157 |
– |
GLX_RED_SIZE,4, GLX_GREEN_SIZE,4, |
| 158 |
– |
GLX_BLUE_SIZE,4, GLX_ALPHA_SIZE,2, |
| 159 |
– |
GLX_DEPTH_SIZE,15, None}; |
| 160 |
– |
#endif |
| 143 |
|
char *ev; |
| 144 |
|
double gamval = GAMMA; |
| 145 |
|
RGBPRIMP dpri = stdprims; |
| 228 |
|
glXMakeCurrent(ourdisplay, gwind, gctx); |
| 229 |
|
glEnable(GL_DEPTH_TEST); |
| 230 |
|
glDepthFunc(GL_LEQUAL); |
| 231 |
< |
glEnable(GL_DITHER); |
| 231 |
> |
glClearColor(0, 0, 0, 0); |
| 232 |
|
glFrontFace(GL_CCW); |
| 233 |
|
glDisable(GL_CULL_FACE); |
| 234 |
|
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); |
| 235 |
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); |
| 236 |
+ |
glPixelStorei(GL_PACK_ALIGNMENT, 1); |
| 237 |
+ |
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); |
| 238 |
|
/* figure out sensible view */ |
| 239 |
|
pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / |
| 240 |
|
DisplayWidth(ourdisplay, ourscreen); |
| 247 |
|
checkglerr("setting rendering parameters"); |
| 248 |
|
copystruct(&odev.v, &stdview); |
| 249 |
|
odev.v.type = VT_PER; |
| 250 |
< |
headlocked = 0; /* free up head movement */ |
| 267 |
< |
viewsteady = 1; /* view starts static */ |
| 268 |
< |
isperspective = -1; /* but no view set, yet */ |
| 250 |
> |
viewflags = VWSTEADY; /* view starts static */ |
| 251 |
|
/* map the window */ |
| 252 |
|
XMapWindow(ourdisplay, gwind); |
| 253 |
|
dev_input(); /* sets size and view angles */ |
| 254 |
|
if (!odInit(DisplayWidth(ourdisplay,ourscreen) * |
| 255 |
< |
DisplayHeight(ourdisplay,ourscreen) / 4)) |
| 255 |
> |
DisplayHeight(ourdisplay,ourscreen) / 3)) |
| 256 |
|
error(SYSTEM, "insufficient memory for value storage"); |
| 257 |
|
odev.name = id; |
| 258 |
|
odev.firstuse = 1; /* can't recycle samples */ |
| 284 |
|
|
| 285 |
|
dev_clear() /* clear our representation */ |
| 286 |
|
{ |
| 287 |
< |
wipeclean(); |
| 287 |
> |
viewflags |= VWCHANGE; /* pretend our view has changed */ |
| 288 |
> |
wipeclean(); /* clean off display and samples */ |
| 289 |
> |
dev_flush(); /* redraw geometry & get depth */ |
| 290 |
|
rayqleft = 0; /* hold off update */ |
| 291 |
|
} |
| 292 |
|
|
| 333 |
|
dev_input(); /* get resize event */ |
| 334 |
|
} |
| 335 |
|
copystruct(&odev.v, nv); /* setview() already called */ |
| 336 |
+ |
viewflags |= VWCHANGE; |
| 337 |
+ |
} |
| 338 |
|
#ifdef STEREO |
| 339 |
< |
copystruct(&vwright, nv); |
| 340 |
< |
d = eyesepdist / sqrt(nv->hn2); |
| 341 |
< |
VSUM(vwright.vp, nv->vp, nv->hvec, d); |
| 342 |
< |
/* setview(&vwright); -- Unnecessary */ |
| 339 |
> |
copystruct(&vwright, nv); |
| 340 |
> |
d = eyesepdist / sqrt(nv->hn2); |
| 341 |
> |
VSUM(vwright.vp, nv->vp, nv->hvec, d); |
| 342 |
> |
/* setview(&vwright); -- Unnecessary */ |
| 343 |
|
#endif |
| 358 |
– |
} |
| 344 |
|
wipeclean(); |
| 345 |
|
return(1); |
| 346 |
|
} |
| 375 |
|
char *cmd, *args; |
| 376 |
|
{ |
| 377 |
|
#ifdef DOBJ |
| 378 |
< |
if (dobj_command(cmd, args) >= 0) |
| 378 |
> |
int vischange; |
| 379 |
> |
|
| 380 |
> |
if ((vischange = dobj_command(cmd, args)) >= 0) { |
| 381 |
> |
if (vischange) { |
| 382 |
> |
imm_mode = beam_sync(1) > 0; |
| 383 |
> |
dev_clear(); |
| 384 |
> |
} |
| 385 |
|
return; |
| 386 |
+ |
} |
| 387 |
|
#endif |
| 388 |
|
sprintf(errmsg, "%s: unknown command", cmd); |
| 389 |
|
error(COMMAND, errmsg); |
| 443 |
|
{ |
| 444 |
|
int ndrawn; |
| 445 |
|
|
| 446 |
< |
if (mapped && isperspective > 0) { |
| 446 |
> |
if ((viewflags&(VWMAPPED|VWPERSP)) == (VWMAPPED|VWPERSP)) { |
| 447 |
|
#ifdef STEREO |
| 448 |
|
pushright(); /* draw right eye */ |
| 449 |
|
ndrawn = gmDrawGeom(); |
| 450 |
|
#ifdef DOBJ |
| 451 |
|
ndrawn += dobj_render(); |
| 452 |
|
#endif |
| 461 |
– |
if (ndrawn && gmPortals) |
| 462 |
– |
gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP); |
| 453 |
|
checkglerr("rendering right eye"); |
| 454 |
|
popright(); /* draw left eye */ |
| 455 |
|
#endif |
| 457 |
|
#ifdef DOBJ |
| 458 |
|
ndrawn += dobj_render(); |
| 459 |
|
#endif |
| 470 |
– |
if (ndrawn && gmPortals) |
| 471 |
– |
gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP); |
| 460 |
|
glXSwapBuffers(ourdisplay, gwind); |
| 461 |
|
checkglerr("rendering base view"); |
| 462 |
|
} |
| 463 |
< |
if (mapped && viewsteady) |
| 464 |
< |
if (isperspective > 0) { /* first time after steady */ |
| 465 |
< |
if (ndrawn) |
| 466 |
< |
xferdepth(); /* transfer and clear depth */ |
| 467 |
< |
setglortho(); /* set orthographic view */ |
| 468 |
< |
} else if (!isperspective) { |
| 463 |
> |
if ((viewflags&(VWMAPPED|VWSTEADY|VWPERSP|VWORTHO)) == |
| 464 |
> |
(VWMAPPED|VWSTEADY|VWPERSP)) { |
| 465 |
> |
/* first time after steady */ |
| 466 |
> |
if (ndrawn) |
| 467 |
> |
xferdepth(); /* transfer and clear depth */ |
| 468 |
> |
setglortho(); /* set orthographic view */ |
| 469 |
> |
|
| 470 |
> |
} |
| 471 |
> |
if ((viewflags&(VWMAPPED|VWSTEADY|VWPERSP|VWORTHO)) == |
| 472 |
> |
(VWMAPPED|VWSTEADY|VWORTHO)) { |
| 473 |
> |
/* else update cones */ |
| 474 |
|
#ifdef STEREO |
| 475 |
< |
pushright(); |
| 476 |
< |
odUpdate(1); /* draw right eye */ |
| 477 |
< |
popright(); |
| 475 |
> |
pushright(); |
| 476 |
> |
odUpdate(1); /* draw right eye */ |
| 477 |
> |
popright(); |
| 478 |
|
#endif |
| 479 |
< |
odUpdate(0); /* draw left eye */ |
| 480 |
< |
glFlush(); /* flush OpenGL */ |
| 481 |
< |
} |
| 479 |
> |
odUpdate(0); /* draw left eye */ |
| 480 |
> |
glFlush(); /* flush OpenGL */ |
| 481 |
> |
} |
| 482 |
|
rayqleft = RAYQLEN; |
| 483 |
|
/* flush X11 and return # pending */ |
| 484 |
|
return(odev.inpready = XPending(ourdisplay)); |
| 502 |
|
xferdepth() /* load and clear depth buffer */ |
| 503 |
|
{ |
| 504 |
|
register GLfloat *dbp; |
| 505 |
< |
register GLubyte *cbuf; |
| 505 |
> |
register GLubyte *pbuf; |
| 506 |
|
|
| 507 |
|
if (depthbuffer == NULL) { /* allocate private depth buffer */ |
| 508 |
|
#ifdef STEREO |
| 515 |
|
} |
| 516 |
|
/* allocate alpha buffer for portals */ |
| 517 |
|
if (gmPortals) |
| 518 |
< |
cbuf = (GLubyte *)malloc(odev.hres*odev.vres * |
| 526 |
< |
(4*sizeof(GLubyte))); |
| 518 |
> |
pbuf = (GLubyte *)malloc(odev.hres*odev.vres*sizeof(GLubyte)); |
| 519 |
|
else |
| 520 |
< |
cbuf = NULL; |
| 520 |
> |
pbuf = NULL; |
| 521 |
|
#ifdef STEREO |
| 522 |
< |
setstereobuf(STEREO_BUFFER_RIGHT); |
| 522 |
> |
pushright(); |
| 523 |
|
glReadPixels(0, 0, odev.hres, odev.vres, |
| 524 |
|
GL_DEPTH_COMPONENT, GL_FLOAT, depthright); |
| 525 |
< |
if (cbuf != NULL) |
| 525 |
> |
if (pbuf != NULL) { |
| 526 |
> |
glClear(GL_COLOR_BUFFER_BIT); |
| 527 |
> |
gmDrawPortals(0xff, -1, -1, -1); |
| 528 |
|
glReadPixels(0, 0, odev.hres, odev.vres, |
| 529 |
< |
GL_RGBA, GL_UNSIGNED_BYTE, cbuf); |
| 529 |
> |
GL_RED, GL_UNSIGNED_BYTE, pbuf); |
| 530 |
> |
} |
| 531 |
|
for (dbp = depthright + odev.hres*odev.vres; dbp-- > depthright; ) |
| 532 |
< |
if (cbuf != NULL && isportal(cbuf+4*(dbp-depthright))) |
| 532 |
> |
if (pbuf != NULL && pbuf[dbp-depthright]&0x40) |
| 533 |
|
*dbp = FHUGE; |
| 534 |
|
else |
| 535 |
|
*dbp = mapdepth(*dbp); |
| 536 |
|
glClear(GL_DEPTH_BUFFER_BIT); |
| 542 |
– |
setstereobuf(STEREO_BUFFER_LEFT); |
| 537 |
|
odDepthMap(1, depthright); |
| 538 |
+ |
popright(); |
| 539 |
|
#endif |
| 540 |
|
/* read back depth buffer */ |
| 541 |
|
glReadPixels(0, 0, odev.hres, odev.vres, |
| 542 |
|
GL_DEPTH_COMPONENT, GL_FLOAT, depthbuffer); |
| 543 |
< |
if (cbuf != NULL) |
| 543 |
> |
if (pbuf != NULL) { |
| 544 |
> |
glClear(GL_COLOR_BUFFER_BIT); /* find portals */ |
| 545 |
> |
gmDrawPortals(0xff, -1, -1, -1); |
| 546 |
|
glReadPixels(0, 0, odev.hres, odev.vres, |
| 547 |
< |
GL_RGBA, GL_UNSIGNED_BYTE, cbuf); |
| 547 |
> |
GL_RED, GL_UNSIGNED_BYTE, pbuf); |
| 548 |
> |
#ifdef DEBUG |
| 549 |
> |
glXSwapBuffers(ourdisplay, gwind); |
| 550 |
> |
#endif |
| 551 |
> |
} |
| 552 |
|
for (dbp = depthbuffer + odev.hres*odev.vres; dbp-- > depthbuffer; ) |
| 553 |
< |
if (cbuf != NULL && isportal(cbuf+4*(dbp-depthbuffer))) |
| 553 |
> |
if (pbuf != NULL && pbuf[dbp-depthbuffer]&0x40) |
| 554 |
|
*dbp = FHUGE; |
| 555 |
|
else |
| 556 |
|
*dbp = mapdepth(*dbp); |
| 557 |
|
glClear(GL_DEPTH_BUFFER_BIT); /* clear system depth buffer */ |
| 557 |
– |
if (cbuf != NULL) |
| 558 |
– |
free((char *)cbuf); /* free our color buffer */ |
| 558 |
|
odDepthMap(0, depthbuffer); /* transfer depth data */ |
| 559 |
+ |
if (pbuf != NULL) |
| 560 |
+ |
free((char *)pbuf); /* free our portal buffer */ |
| 561 |
|
} |
| 562 |
|
|
| 563 |
|
|
| 583 |
|
FVECT direc; |
| 584 |
|
{ |
| 585 |
|
GLfloat gldepth; |
| 585 |
– |
GLubyte glcolor[4]; |
| 586 |
|
double dist; |
| 587 |
|
|
| 588 |
|
if (dx<0 | dx>=odev.hres | dy<0 | dy>=odev.vres) |
| 592 |
|
else { |
| 593 |
|
glReadPixels(dx,dy, 1,1, GL_DEPTH_COMPONENT, |
| 594 |
|
GL_FLOAT, &gldepth); |
| 595 |
– |
if (gmPortals) { |
| 596 |
– |
glReadPixels(dx,dy, 1,1, GL_RGBA, |
| 597 |
– |
GL_UNSIGNED_BYTE, glcolor); |
| 598 |
– |
if (isportal(glcolor)) |
| 599 |
– |
return(FHUGE); |
| 600 |
– |
} |
| 595 |
|
dist = mapdepth(gldepth); |
| 596 |
|
} |
| 597 |
|
if (dist >= .99*FHUGE) |
| 607 |
|
double d; |
| 608 |
|
|
| 609 |
|
setstereobuf(STEREO_BUFFER_RIGHT); |
| 610 |
< |
if (isperspective > 0) { |
| 610 |
> |
if (viewflags & VWPERSP) { |
| 611 |
|
glMatrixMode(GL_MODELVIEW); |
| 612 |
|
glPushMatrix(); |
| 613 |
|
d = -eyesepdist / sqrt(odev.v.hn2); |
| 621 |
|
static |
| 622 |
|
popright() /* pop off right view & buffer */ |
| 623 |
|
{ |
| 624 |
< |
if (isperspective > 0) { |
| 624 |
> |
if (viewflags & VWPERSP) { |
| 625 |
|
glMatrixMode(GL_MODELVIEW); |
| 626 |
|
glPopMatrix(); |
| 627 |
|
} |
| 664 |
|
resizewindow(levptr(XConfigureEvent)); |
| 665 |
|
break; |
| 666 |
|
case UnmapNotify: |
| 667 |
< |
mapped = 0; |
| 667 |
> |
viewflags &= ~VWMAPPED; |
| 668 |
|
break; |
| 669 |
|
case MapNotify: |
| 670 |
|
odRemap(0); |
| 671 |
< |
mapped = 1; |
| 671 |
> |
viewflags |= VWMAPPED; |
| 672 |
|
break; |
| 673 |
|
case Expose: |
| 674 |
|
fixwindow(levptr(XExposeEvent)); |
| 702 |
|
glPushAttrib(GL_LIGHTING_BIT|GL_ENABLE_BIT); |
| 703 |
|
glDisable(GL_LIGHTING); |
| 704 |
|
if (fore) |
| 705 |
< |
glColor3ub(0, 255, 255); |
| 705 |
> |
glColor3ub(4, 250, 250); |
| 706 |
|
else |
| 707 |
|
glColor3ub(0, 0, 0); |
| 708 |
|
glBegin(GL_LINES); /* draw each grid line */ |
| 755 |
|
d = MOVPCT/100. * mov; |
| 756 |
|
VSUM(nv.vp, nv.vp, odir, d); |
| 757 |
|
} |
| 758 |
< |
if (!mov ^ !orb && headlocked) { /* restore head height */ |
| 758 |
> |
if (!mov ^ !orb && viewflags&VWHEADLOCK) { /* restore height */ |
| 759 |
|
VSUM(v1, odev.v.vp, nv.vp, -1.); |
| 760 |
|
d = DOT(v1, nv.vup); |
| 761 |
|
VSUM(nv.vp, nv.vp, odev.v.vup, d); |
| 804 |
|
|
| 805 |
|
XNoOp(ourdisplay); /* makes sure we're not idle */ |
| 806 |
|
|
| 807 |
< |
viewsteady = 0; /* flag moving view */ |
| 808 |
< |
setglpersp(&odev.v); /* start us off in perspective */ |
| 807 |
> |
viewflags &= ~VWSTEADY; /* flag moving view */ |
| 808 |
> |
setglpersp(); /* start us off in perspective */ |
| 809 |
|
while (!XCheckMaskEvent(ourdisplay, |
| 810 |
|
ButtonReleaseMask, levptr(XEvent))) { |
| 811 |
|
/* get cursor position */ |
| 825 |
|
#ifdef DOBJ |
| 826 |
|
ndrawn += dobj_render(); |
| 827 |
|
#endif |
| 834 |
– |
if (ndrawn && gmPortals) |
| 835 |
– |
gmDrawPortals(PORTRED,PORTGRN,PORTBLU,PORTALP); |
| 828 |
|
popright(); |
| 829 |
|
#endif |
| 830 |
|
/* redraw octrees */ |
| 832 |
|
#ifdef DOBJ |
| 833 |
|
ndrawn += dobj_render(); /* redraw objects */ |
| 834 |
|
#endif |
| 843 |
– |
if (ndrawn && gmPortals) |
| 844 |
– |
gmDrawPortals(PORTRED, PORTGRN, PORTBLU, PORTALP); |
| 835 |
|
glXSwapBuffers(ourdisplay, gwind); |
| 836 |
|
if (!ndrawn) |
| 837 |
|
sleep(1); /* for reasonable interaction */ |
| 842 |
|
wy = levptr(XButtonReleasedEvent)->y; |
| 843 |
|
moveview(wx, odev.vres-1-wy, movdir, movorb); |
| 844 |
|
} |
| 845 |
< |
viewsteady = 1; /* done goofing around */ |
| 845 |
> |
viewflags |= VWSTEADY; /* done goofing around */ |
| 846 |
|
} |
| 847 |
|
|
| 848 |
|
|
| 849 |
|
static |
| 850 |
< |
setglpersp(vp) /* set perspective view in GL */ |
| 861 |
< |
register VIEW *vp; |
| 850 |
> |
setglpersp() /* set perspective view in GL */ |
| 851 |
|
{ |
| 852 |
|
double d, xmin, xmax, ymin, ymax; |
| 853 |
|
GLfloat vec[4]; |
| 859 |
|
dev_zmax = 100.; |
| 860 |
|
} else { |
| 861 |
|
dev_zmin = 0.5*depthlim[0]; |
| 862 |
< |
dev_zmax = 1.75*depthlim[1]; |
| 862 |
> |
dev_zmax = 1.25*depthlim[1]; |
| 863 |
|
if (dev_zmin > dev_zmax/5.) |
| 864 |
|
dev_zmin = dev_zmax/5.; |
| 865 |
|
} |
| 888 |
|
odev.v.vp[2] + odev.v.vdir[2], |
| 889 |
|
odev.v.vup[0], odev.v.vup[1], odev.v.vup[2]); |
| 890 |
|
checkglerr("setting perspective view"); |
| 902 |
– |
isperspective = 1; |
| 891 |
|
vec[0] = vec[1] = vec[2] = 0.; vec[3] = 1.; |
| 892 |
|
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, vec); |
| 893 |
|
vec[0] = -odev.v.vdir[0]; |
| 903 |
|
glEnable(GL_LIGHT0); |
| 904 |
|
glEnable(GL_LIGHTING); /* light our GL objects */ |
| 905 |
|
glShadeModel(GL_SMOOTH); |
| 906 |
+ |
viewflags &= ~VWORTHO; |
| 907 |
+ |
viewflags |= VWPERSP; |
| 908 |
|
} |
| 909 |
|
|
| 910 |
|
|
| 918 |
|
glOrtho(0., (double)odev.hres, 0., (double)odev.vres, |
| 919 |
|
0.001*OMAXDEPTH, 1.001*(-OMAXDEPTH)); |
| 920 |
|
checkglerr("setting orthographic view"); |
| 931 |
– |
isperspective = 0; |
| 921 |
|
glDisable(GL_LIGHTING); /* cones are constant color */ |
| 922 |
|
glShadeModel(GL_FLAT); |
| 923 |
+ |
viewflags &= ~VWPERSP; |
| 924 |
+ |
viewflags |= VWORTHO; |
| 925 |
|
} |
| 926 |
|
|
| 927 |
|
|
| 929 |
|
wipeclean() /* prepare for redraw */ |
| 930 |
|
{ |
| 931 |
|
glDrawBuffer(GL_BACK); /* use double-buffer mode */ |
| 932 |
+ |
glReadBuffer(GL_BACK); |
| 933 |
|
/* clear buffers */ |
| 934 |
|
#ifdef STEREO |
| 935 |
|
setstereobuf(STEREO_BUFFER_RIGHT); |
| 938 |
|
#endif |
| 939 |
|
glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); |
| 940 |
|
freedepth(); |
| 941 |
< |
if (viewsteady) /* clear samples if steady */ |
| 941 |
> |
if ((viewflags&(VWCHANGE|VWSTEADY)) == |
| 942 |
> |
(VWCHANGE|VWSTEADY)) { /* clear samples if new */ |
| 943 |
|
odClean(); |
| 944 |
+ |
viewflags &= ~VWCHANGE; /* change noted */ |
| 945 |
+ |
} else if (viewflags & VWSTEADY) |
| 946 |
+ |
odRedrawAll(); |
| 947 |
|
setglpersp(&odev.v); /* reset view & clipping planes */ |
| 948 |
|
} |
| 949 |
|
|
| 963 |
|
return; |
| 964 |
|
switch (buf[0]) { |
| 965 |
|
case 'h': /* turn on height motion lock */ |
| 966 |
< |
headlocked = 1; |
| 966 |
> |
viewflags |= VWHEADLOCK; |
| 967 |
|
return; |
| 968 |
|
case 'H': /* turn off height motion lock */ |
| 969 |
< |
headlocked = 0; |
| 969 |
> |
viewflags &= ~VWHEADLOCK; |
| 970 |
|
return; |
| 971 |
|
case 'l': /* retrieve last view */ |
| 972 |
|
inpresflags |= DFL(DC_LASTVIEW); |
| 994 |
|
inpresflags |= DFL(DC_RESUME); |
| 995 |
|
return; |
| 996 |
|
case CTRL('R'): /* redraw screen */ |
| 997 |
< |
odRemap(0); |
| 997 |
> |
odRemap(0); /* new tone mapping */ |
| 998 |
|
glClear(GL_DEPTH_BUFFER_BIT); |
| 999 |
|
#ifdef STEREO |
| 1000 |
|
setstereobuf(STEREO_BUFFER_RIGHT); |
| 1004 |
|
return; |
| 1005 |
|
case CTRL('L'): /* refresh from server */ |
| 1006 |
|
if (inpresflags & DFL(DC_REDRAW)) |
| 1007 |
< |
return; |
| 1007 |
> |
return; /* already called */ |
| 1008 |
|
XRaiseWindow(ourdisplay, gwind); |
| 1009 |
< |
XFlush(ourdisplay); |
| 1010 |
< |
sleep(1); |
| 1011 |
< |
wipeclean(); /* fresh display */ |
| 1012 |
< |
odRemap(1); /* fresh tone mapping */ |
| 1017 |
< |
dev_flush(); /* draw octrees */ |
| 1009 |
> |
XFlush(ourdisplay); /* raise up window */ |
| 1010 |
> |
sleep(1); /* wait for restacking */ |
| 1011 |
> |
dev_clear(); /* clear buffer and samples */ |
| 1012 |
> |
odRemap(1); /* start fresh histogram */ |
| 1013 |
|
inpresflags |= DFL(DC_REDRAW); /* resend values from server */ |
| 1019 |
– |
rayqleft = 0; /* hold off update */ |
| 1014 |
|
return; |
| 1015 |
|
case 'K': /* kill rtrace process(es) */ |
| 1016 |
|
inpresflags |= DFL(DC_KILL); |
| 1043 |
|
} |
| 1044 |
|
xmin = eexp->x; xmax = eexp->x + eexp->width; |
| 1045 |
|
ymin = odev.vres - eexp->y - eexp->height; ymax = odev.vres - eexp->y; |
| 1046 |
+ |
|
| 1047 |
+ |
if (xmin <= 0 && xmax >= odev.hres-1 && |
| 1048 |
+ |
ymin <= 0 && ymax >= odev.vres) { |
| 1049 |
+ |
DCHECK(eexp->count, WARNING, "multiple clear in fixwindow"); |
| 1050 |
+ |
wipeclean(); /* make sure we're go */ |
| 1051 |
+ |
return; |
| 1052 |
+ |
} |
| 1053 |
|
/* clear portion of depth */ |
| 1054 |
|
glPushAttrib(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT); |
| 1055 |
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); |
| 1092 |
|
odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres); |
| 1093 |
|
|
| 1094 |
|
inpresflags |= DFL(DC_SETVIEW); |
| 1095 |
+ |
viewflags |= VWCHANGE; |
| 1096 |
|
} |