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 |
94 |
|
char *id; |
95 |
|
{ |
96 |
|
extern char *getenv(); |
97 |
+ |
static RGBPRIMS myprims = STDPRIMS; |
98 |
|
static int atlBest[] = {GLX_RGBA, GLX_RED_SIZE,8, |
99 |
|
GLX_GREEN_SIZE,8, GLX_BLUE_SIZE,8, |
100 |
|
GLX_DEPTH_SIZE,15, None}; |
101 |
< |
char *gv; |
101 |
> |
char *ev; |
102 |
|
double gamval = GAMMA; |
103 |
+ |
RGBPRIMP dpri = stdprims; |
104 |
|
XSetWindowAttributes ourwinattr; |
105 |
|
XWMHints ourxwmhints; |
106 |
|
XSizeHints oursizhints; |
107 |
|
/* set quadtree globals */ |
108 |
|
qtMinNodesiz = 3; |
109 |
+ |
qtDepthEps = 0.07; |
110 |
|
/* open display server */ |
111 |
|
ourdisplay = XOpenDisplay(NULL); |
112 |
|
if (ourdisplay == NULL) |
118 |
|
/* get a context */ |
119 |
|
gctx = glXCreateContext(ourdisplay, ourvinf, NULL, GL_TRUE); |
120 |
|
/* set gamma and tone mapping */ |
121 |
< |
if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL |
122 |
< |
|| (gv = getenv("DISPLAY_GAMMA")) != NULL) |
123 |
< |
gamval = atof(gv); |
124 |
< |
if (tmInit(mytmflags(), stdprims, gamval) == NULL) |
121 |
> |
if ((ev = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL |
122 |
> |
|| (ev = getenv("DISPLAY_GAMMA")) != NULL) |
123 |
> |
gamval = atof(ev); |
124 |
> |
if ((ev = getenv("DISPLAY_PRIMARIES")) != NULL && |
125 |
> |
sscanf(ev, "%f %f %f %f %f %f %f %f", |
126 |
> |
&myprims[RED][CIEX],&myprims[RED][CIEY], |
127 |
> |
&myprims[GRN][CIEX],&myprims[GRN][CIEY], |
128 |
> |
&myprims[BLU][CIEX],&myprims[BLU][CIEY], |
129 |
> |
&myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) |
130 |
> |
dpri = myprims; |
131 |
> |
if (tmInit(mytmflags(), dpri, gamval) == NULL) |
132 |
|
error(SYSTEM, "not enough memory in dev_open"); |
133 |
|
/* open window */ |
134 |
|
ourwinattr.background_pixel = ourblack; |
175 |
|
/* map the window */ |
176 |
|
XMapWindow(ourdisplay, gwind); |
177 |
|
dev_input(); /* sets size and view angles */ |
164 |
– |
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
178 |
|
/* allocate our leaf pile */ |
179 |
< |
if (!qtAllocLeaves(2 * DisplayWidth(ourdisplay,ourscreen) * |
180 |
< |
DisplayHeight(ourdisplay,ourscreen) / |
181 |
< |
(qtMinNodesiz*qtMinNodesiz))) |
179 |
> |
if (!qtAllocLeaves(DisplayWidth(ourdisplay,ourscreen) * |
180 |
> |
DisplayHeight(ourdisplay,ourscreen) * 3 / |
181 |
> |
(qtMinNodesiz*qtMinNodesiz*2))) |
182 |
|
error(SYSTEM, "insufficient memory for value storage"); |
183 |
|
odev.name = id; |
184 |
|
odev.ifd = ConnectionNumber(ourdisplay); |
204 |
|
} |
205 |
|
|
206 |
|
|
207 |
+ |
dev_clear() /* clear our quadtree */ |
208 |
+ |
{ |
209 |
+ |
qtCompost(100); |
210 |
+ |
glClear(GL_DEPTH_BUFFER_BIT); |
211 |
+ |
rayqleft = 0; /* hold off update */ |
212 |
+ |
} |
213 |
+ |
|
214 |
+ |
|
215 |
|
int |
216 |
|
dev_view(nv) /* assign new driver view */ |
217 |
|
register VIEW *nv; |
283 |
|
{ |
284 |
|
qtUpdate(); |
285 |
|
glFlush(); |
286 |
+ |
rayqleft = RAYQLEN; |
287 |
|
return(XPending(ourdisplay)); |
288 |
|
} |
289 |
|
|
295 |
|
{ |
296 |
|
register int ci, j; |
297 |
|
double apexh, basez; |
298 |
+ |
/* is window mapped? */ |
299 |
+ |
if (!mapped) |
300 |
+ |
return; |
301 |
|
/* compute apex height (0. to 1.) */ |
302 |
|
if (ip[2] > 1e6) |
303 |
|
apexh = 1. - 1./DEPTHFACT; |
339 |
|
for (cp = tail; *cp && *cp != '.'; cp++) |
340 |
|
; |
341 |
|
if (cp-tail == 3 && !strncmp(tail, "glx", 3)) |
342 |
< |
return(TM_F_CAMERA); |
342 |
> |
return(TM_F_CAMERA|TM_F_NOSTDERR); |
343 |
|
if (cp-tail == 4 && !strncmp(tail, "glxh", 4)) |
344 |
< |
return(TM_F_HUMAN); |
344 |
> |
return(TM_F_HUMAN|TM_F_NOSTDERR); |
345 |
|
error(USER, "illegal driver name"); |
346 |
|
} |
347 |
|
|
592 |
|
inpresflags |= DFL(DC_RESUME); |
593 |
|
return; |
594 |
|
case CTRL('R'): /* redraw screen */ |
595 |
+ |
if (nxtzmax > FTINY) { |
596 |
+ |
curzmax = nxtzmax; |
597 |
+ |
nxtzmax = 0.; |
598 |
+ |
} |
599 |
|
glClear(GL_DEPTH_BUFFER_BIT); |
600 |
|
qtRedraw(0, 0, odev.hres, odev.vres); |
601 |
|
return; |
602 |
|
case CTRL('L'): /* refresh from server */ |
603 |
|
if (inpresflags & DFL(DC_REDRAW)) |
604 |
|
return; |
605 |
+ |
if (nxtzmax > FTINY) { |
606 |
+ |
curzmax = nxtzmax; |
607 |
+ |
nxtzmax = 0.; |
608 |
+ |
} |
609 |
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
610 |
|
draw_grids(); |
611 |
|
glFlush(); |
612 |
|
qtCompost(100); /* get rid of old values */ |
613 |
|
inpresflags |= DFL(DC_REDRAW); /* resend values from server */ |
614 |
+ |
rayqleft = 0; /* hold off update */ |
615 |
|
return; |
616 |
|
case 'K': /* kill rtrace process(es) */ |
617 |
|
inpresflags |= DFL(DC_KILL); |