--- ray/src/hd/rhd_x11.c 1997/12/19 14:44:58 3.17 +++ ray/src/hd/rhd_x11.c 1998/01/06 13:07:57 3.24 @@ -18,6 +18,10 @@ static char SCCSid[] = "$SunId$ SGI"; #include "x11icon.h" +#ifndef RAYQLEN +#define RAYQLEN 50000 /* max. rays to queue before flush */ +#endif + #ifndef FEQ #define FEQ(a,b) ((a)-(b) <= FTINY && (a)-(b) >= -FTINY) #endif @@ -81,9 +85,9 @@ mytmflags() /* figure out tone mapping flags */ for (cp = tail; *cp && *cp != '.'; cp++) ; if (cp-tail == 3 && !strncmp(tail, "x11", 3)) - return(TM_F_CAMERA); + return(TM_F_CAMERA|TM_F_NOSTDERR); if (cp-tail == 4 && !strncmp(tail, "x11h", 4)) - return(TM_F_HUMAN); + return(TM_F_HUMAN|TM_F_NOSTDERR); error(USER, "illegal driver name"); } @@ -92,8 +96,10 @@ dev_open(id) /* initialize X11 driver */ char *id; { extern char *getenv(); - char *gv; + static RGBPRIMS myprims = STDPRIMS; + char *ev; double gamval = GAMMA; + RGBPRIMP dpri = stdprims; int nplanes; XSetWindowAttributes ourwinattr; XWMHints ourxwmhints; @@ -126,10 +132,17 @@ char *id; ourwhite = WhitePixel(ourdisplay,ourscreen); } /* set gamma and tone mapping */ - if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL - || (gv = getenv("DISPLAY_GAMMA")) != NULL) - gamval = atof(gv); - if (tmInit(mytmflags(), stdprims, gamval) == NULL) + if ((ev = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL + || (ev = getenv("DISPLAY_GAMMA")) != NULL) + gamval = atof(ev); + if ((ev = getenv("DISPLAY_PRIMARIES")) != NULL && + sscanf(ev, "%f %f %f %f %f %f %f %f", + &myprims[RED][CIEX],&myprims[RED][CIEY], + &myprims[GRN][CIEX],&myprims[GRN][CIEY], + &myprims[BLU][CIEX],&myprims[BLU][CIEY], + &myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) + dpri = myprims; + if (tmInit(mytmflags(), dpri, gamval) == NULL) error(SYSTEM, "not enough memory in dev_open"); /* open window */ ourwinattr.background_pixel = ourblack; @@ -158,25 +171,22 @@ char *id; oursizhints.min_height = MINHEIGHT; oursizhints.flags = PMinSize; XSetNormalHints(ourdisplay, gwind, &oursizhints); - /* map the window and get its size */ - XMapWindow(ourdisplay, gwind); - dev_input(); - /* allocate our leaf pile */ - if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) * - DisplayHeight(ourdisplay,ourscreen) / - (qtMinNodesiz*qtMinNodesiz))) - error(SYSTEM, "insufficient memory for leaf storage"); - /* figure out sensible view */ pwidth = (double)DisplayWidthMM(ourdisplay, ourscreen) / DisplayWidth(ourdisplay, ourscreen); pheight = (double)DisplayHeightMM(ourdisplay, ourscreen) / DisplayHeight(ourdisplay, ourscreen); copystruct(&odev.v, &stdview); - odev.name = id; odev.v.type = VT_PER; - odev.v.horiz = 2.*180./PI * atan(0.5/VIEWDIST*pwidth*odev.hres); - odev.v.vert = 2.*180./PI * atan(0.5/VIEWDIST*pheight*odev.vres); + /* map the window and get its size */ + XMapWindow(ourdisplay, gwind); + dev_input(); /* sets size and view angles */ + /* allocate our leaf pile */ + if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) * + DisplayHeight(ourdisplay,ourscreen) * 3 / + (qtMinNodesiz*qtMinNodesiz*2))) + error(SYSTEM, "insufficient memory for leaf storage"); + odev.name = id; odev.ifd = ConnectionNumber(ourdisplay); } @@ -198,6 +208,16 @@ dev_close() /* close our display */ } + +dev_clear() /* clear our quadtree */ +{ + qtCompost(100); + if (ncolors > 0) + new_ctab(ncolors); + rayqleft = 0; /* hold off update */ +} + + int dev_view(nv) /* assign new driver view */ VIEW *nv; @@ -236,6 +256,7 @@ VIEW *nv; odev.vres = dh; } XResizeWindow(ourdisplay, gwind, odev.hres, odev.vres); + dev_input(); /* wait for resize event */ } copystruct(&odev.v, nv); } @@ -280,6 +301,7 @@ int dev_flush() /* flush output */ { qtUpdate(); + rayqleft = RAYQLEN; return(XPending(ourdisplay)); } @@ -455,7 +477,7 @@ draw_grids() /* draw holodeck section grids */ static BYTE gridrgb[3] = {0x0, 0xff, 0xff}; unsigned long pixel; - if (!mapped || odev.v.type != VT_PER) + if (!mapped) return; if (ncolors > 0) pixel = pixval[get_pixel(gridrgb, xnewcolr)]; @@ -601,6 +623,7 @@ register XKeyPressedEvent *ekey; if (ncolors > 0) new_ctab(ncolors); inpresflags |= DFL(DC_REDRAW); /* resend values from server */ + rayqleft = 0; /* hold off update */ return; case 'K': /* kill rtrace process(es) */ inpresflags |= DFL(DC_KILL);