--- ray/src/hd/rhd_ogl.c 1998/12/23 17:43:42 3.10 +++ ray/src/hd/rhd_ogl.c 1999/01/05 18:16:17 3.15 @@ -1,4 +1,4 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ +/* Copyright (c) 1999 Silicon Graphics, Inc. */ #ifndef lint static char SCCSid[] = "$SunId$ SGI"; @@ -37,8 +37,18 @@ static char SCCSid[] = "$SunId$ SGI"; #include "x11icon.h" #ifndef RAYQLEN -#define RAYQLEN 50000 /* max. rays to queue before flush */ +#define RAYQLEN 0 /* max. rays to queue before flush */ #endif +#ifndef MINWIDTH +#define MINWIDTH 480 /* minimum graphics window width */ +#define MINHEIGHT 400 /* minimum graphics window height */ +#endif +#ifndef VIEWDIST +#define VIEWDIST 356 /* assumed viewing distance (mm) */ +#endif +#ifndef BORWIDTH +#define BORWIDTH 5 /* border width */ +#endif #ifndef FEQ #define FEQ(a,b) ((a)-(b) <= FTINY && (a)-(b) >= -FTINY) @@ -60,13 +70,6 @@ static char SCCSid[] = "$SunId$ SGI"; #define MOVDEG (-5) /* degrees to orbit CW/down /frame */ #define MOVORB(s) ((s)&ShiftMask ? 1 : (s)&ControlMask ? -1 : 0) -#define MINWIDTH 480 /* minimum graphics window width */ -#define MINHEIGHT 400 /* minimum graphics window height */ - -#define VIEWDIST 356 /* assumed viewing distance (mm) */ - -#define BORWIDTH 5 /* border width */ - #define setstereobuf(bid) (glXWaitGL(), \ XSGISetStereoBuffer(ourdisplay, gwind, bid), \ glXWaitX()) @@ -250,7 +253,7 @@ char *id; XMapWindow(ourdisplay, gwind); dev_input(); /* sets size and view angles */ if (!odInit(DisplayWidth(ourdisplay,ourscreen) * - DisplayHeight(ourdisplay,ourscreen) / 4)) + DisplayHeight(ourdisplay,ourscreen) / 3)) error(SYSTEM, "insufficient memory for value storage"); odev.name = id; odev.firstuse = 1; /* can't recycle samples */ @@ -284,6 +287,7 @@ dev_clear() /* clear our representation */ { viewflags |= VWCHANGE; /* pretend our view has changed */ wipeclean(); /* clean off display and samples */ + dev_flush(); /* redraw geometry & get depth */ rayqleft = 0; /* hold off update */ } @@ -330,14 +334,14 @@ register VIEW *nv; dev_input(); /* get resize event */ } copystruct(&odev.v, nv); /* setview() already called */ -#ifdef STEREO - copystruct(&vwright, nv); - d = eyesepdist / sqrt(nv->hn2); - VSUM(vwright.vp, nv->vp, nv->hvec, d); - /* setview(&vwright); -- Unnecessary */ -#endif viewflags |= VWCHANGE; } +#ifdef STEREO + copystruct(&vwright, nv); + d = eyesepdist / sqrt(nv->hn2); + VSUM(vwright.vp, nv->vp, nv->hvec, d); + /* setview(&vwright); -- Unnecessary */ +#endif wipeclean(); return(1); } @@ -372,8 +376,15 @@ dev_auxcom(cmd, args) /* process an auxiliary command char *cmd, *args; { #ifdef DOBJ - if (dobj_command(cmd, args) >= 0) + int vischange; + + if ((vischange = dobj_command(cmd, args)) >= 0) { + if (vischange) { + imm_mode = beam_sync(1) > 0; + dev_clear(); + } return; + } #endif sprintf(errmsg, "%s: unknown command", cmd); error(COMMAND, errmsg); @@ -509,7 +520,7 @@ xferdepth() /* load and clear depth buffer */ else pbuf = NULL; #ifdef STEREO - setstereobuf(STEREO_BUFFER_RIGHT); + pushright(); glReadPixels(0, 0, odev.hres, odev.vres, GL_DEPTH_COMPONENT, GL_FLOAT, depthright); if (pbuf != NULL) { @@ -524,8 +535,8 @@ xferdepth() /* load and clear depth buffer */ else *dbp = mapdepth(*dbp); glClear(GL_DEPTH_BUFFER_BIT); - setstereobuf(STEREO_BUFFER_LEFT); odDepthMap(1, depthright); + popright(); #endif /* read back depth buffer */ glReadPixels(0, 0, odev.hres, odev.vres, @@ -795,7 +806,7 @@ XButtonPressedEvent *ebut; XNoOp(ourdisplay); /* makes sure we're not idle */ viewflags &= ~VWSTEADY; /* flag moving view */ - setglpersp(&odev.v); /* start us off in perspective */ + setglpersp(); /* start us off in perspective */ while (!XCheckMaskEvent(ourdisplay, ButtonReleaseMask, levptr(XEvent))) { /* get cursor position */ @@ -837,8 +848,7 @@ XButtonPressedEvent *ebut; static -setglpersp(vp) /* set perspective view in GL */ -register VIEW *vp; +setglpersp() /* set perspective view in GL */ { double d, xmin, xmax, ymin, ymax; GLfloat vec[4]; @@ -850,7 +860,7 @@ register VIEW *vp; dev_zmax = 100.; } else { dev_zmin = 0.5*depthlim[0]; - dev_zmax = 2.0*depthlim[1]; + dev_zmax = 1.25*depthlim[1]; if (dev_zmin > dev_zmax/5.) dev_zmin = dev_zmax/5.; } @@ -995,12 +1005,11 @@ register XKeyPressedEvent *ekey; return; case CTRL('L'): /* refresh from server */ if (inpresflags & DFL(DC_REDRAW)) - return; + return; /* already called */ XRaiseWindow(ourdisplay, gwind); - XFlush(ourdisplay); + XFlush(ourdisplay); /* raise up window */ sleep(1); /* wait for restacking */ - dev_clear(); /* clear display and samples */ - dev_flush(); /* draw octrees */ + dev_clear(); /* clear buffer and samples */ odRemap(1); /* start fresh histogram */ inpresflags |= DFL(DC_REDRAW); /* resend values from server */ return; @@ -1039,15 +1048,7 @@ register XExposeEvent *eexp; if (xmin <= 0 && xmax >= odev.hres-1 && ymin <= 0 && ymax >= odev.vres) { DCHECK(eexp->count, WARNING, "multiple clear in fixwindow"); - if (viewflags & VWORTHO) /* workaround for... */ - glDrawBuffer(GL_FRONT); /* ...GLX window mapping bug */ - glClear(GL_DEPTH_BUFFER_BIT); /* clear the entire buffer */ -#ifdef STEREO - setstereobuf(STEREO_BUFFER_RIGHT); - glClear(GL_DEPTH_BUFFER_BIT); - setstereobuf(STEREO_BUFFER_LEFT); -#endif - odRedrawAll(); + wipeclean(); /* make sure we're go */ return; } /* clear portion of depth */