1 |
< |
/* Copyright (c) 1997 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
10 |
|
*/ |
11 |
|
|
12 |
|
#include "standard.h" |
13 |
– |
#include "rhd_qtree.h" |
14 |
– |
|
13 |
|
#include <X11/Xlib.h> |
14 |
|
#include <X11/cursorfont.h> |
15 |
|
#include <X11/Xutil.h> |
16 |
< |
|
16 |
> |
#include "rhd_qtree.h" |
17 |
|
#include "x11icon.h" |
18 |
|
|
19 |
|
#ifndef RAYQLEN |
94 |
|
char *id; |
95 |
|
{ |
96 |
|
extern char *getenv(); |
97 |
< |
char *gv; |
97 |
> |
static RGBPRIMS myprims = STDPRIMS; |
98 |
> |
char *ev; |
99 |
|
double gamval = GAMMA; |
100 |
+ |
RGBPRIMP dpri = stdprims; |
101 |
|
int nplanes; |
102 |
|
XSetWindowAttributes ourwinattr; |
103 |
|
XWMHints ourxwmhints; |
130 |
|
ourwhite = WhitePixel(ourdisplay,ourscreen); |
131 |
|
} |
132 |
|
/* set gamma and tone mapping */ |
133 |
< |
if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL |
134 |
< |
|| (gv = getenv("DISPLAY_GAMMA")) != NULL) |
135 |
< |
gamval = atof(gv); |
136 |
< |
if (tmInit(mytmflags(), stdprims, gamval) == NULL) |
133 |
> |
if ((ev = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL |
134 |
> |
|| (ev = getenv("DISPLAY_GAMMA")) != NULL) |
135 |
> |
gamval = atof(ev); |
136 |
> |
if ((ev = getenv("DISPLAY_PRIMARIES")) != NULL && |
137 |
> |
sscanf(ev, "%f %f %f %f %f %f %f %f", |
138 |
> |
&myprims[RED][CIEX],&myprims[RED][CIEY], |
139 |
> |
&myprims[GRN][CIEX],&myprims[GRN][CIEY], |
140 |
> |
&myprims[BLU][CIEX],&myprims[BLU][CIEY], |
141 |
> |
&myprims[WHT][CIEX],&myprims[WHT][CIEY]) >= 6) |
142 |
> |
dpri = myprims; |
143 |
> |
if (tmInit(mytmflags(), dpri, gamval) == NULL) |
144 |
|
error(SYSTEM, "not enough memory in dev_open"); |
145 |
|
/* open window */ |
146 |
|
ourwinattr.background_pixel = ourblack; |
206 |
|
} |
207 |
|
|
208 |
|
|
209 |
+ |
|
210 |
+ |
dev_clear() /* clear our quadtree */ |
211 |
+ |
{ |
212 |
+ |
qtCompost(100); |
213 |
+ |
if (ncolors > 0) |
214 |
+ |
new_ctab(ncolors); |
215 |
+ |
rayqleft = 0; /* hold off update */ |
216 |
+ |
} |
217 |
+ |
|
218 |
+ |
|
219 |
|
int |
220 |
|
dev_view(nv) /* assign new driver view */ |
221 |
|
VIEW *nv; |
263 |
|
} |
264 |
|
|
265 |
|
|
266 |
+ |
dev_auxcom(cmd, args) /* process an auxiliary command */ |
267 |
+ |
char *cmd, *args; |
268 |
+ |
{ |
269 |
+ |
sprintf(errmsg, "%s: unknown command", cmd); |
270 |
+ |
error(COMMAND, errmsg); |
271 |
+ |
} |
272 |
+ |
|
273 |
+ |
|
274 |
+ |
VIEW * |
275 |
+ |
dev_auxview(n, hvres) /* return nth auxiliary view */ |
276 |
+ |
int n; |
277 |
+ |
int hvres[2]; |
278 |
+ |
{ |
279 |
+ |
if (n) |
280 |
+ |
return(NULL); |
281 |
+ |
hvres[0] = odev.hres; hvres[1] = odev.vres; |
282 |
+ |
return(&odev.v); |
283 |
+ |
} |
284 |
+ |
|
285 |
+ |
|
286 |
|
int |
287 |
|
dev_input() /* get X11 input */ |
288 |
|
{ |
291 |
|
do |
292 |
|
getevent(); |
293 |
|
|
294 |
< |
while (XQLength(ourdisplay) > 0); |
294 |
> |
while (XPending(ourdisplay) > 0); |
295 |
|
|
296 |
+ |
odev.inpready = 0; |
297 |
+ |
|
298 |
|
return(inpresflags); |
299 |
|
} |
300 |
|
|
322 |
|
{ |
323 |
|
qtUpdate(); |
324 |
|
rayqleft = RAYQLEN; |
325 |
< |
return(XPending(ourdisplay)); |
325 |
> |
return(odev.inpready = XPending(ourdisplay)); |
326 |
|
} |
327 |
|
|
328 |
|
|
462 |
|
int dp[2][2]; |
463 |
|
FVECT wp[2]; |
464 |
|
{ |
465 |
< |
static FVECT vmin = {0.,0.,0.}, vmax = {1.,1.,FHUGE}; |
466 |
< |
FVECT ip[2]; |
467 |
< |
/* not exactly right, but who cares? */ |
468 |
< |
viewloc(ip[0], &odev.v, wp[0]); |
469 |
< |
viewloc(ip[1], &odev.v, wp[1]); |
465 |
> |
static FVECT vmin = {0.,0.,0.}, vmax = {1.-FTINY,1.-FTINY,FHUGE}; |
466 |
> |
FVECT wpc[2], ip[2]; |
467 |
> |
double d, d0, d1; |
468 |
> |
/* check for points behind view */ |
469 |
> |
d = DOT(odev.v.vp, odev.v.vdir); |
470 |
> |
d0 = DOT(wp[0], odev.v.vdir) - d; |
471 |
> |
d1 = DOT(wp[1], odev.v.vdir) - d; |
472 |
> |
/* work on copy of world points */ |
473 |
> |
if (d0 <= d1) { |
474 |
> |
VCOPY(wpc[0], wp[0]); VCOPY(wpc[1], wp[1]); |
475 |
> |
} else { |
476 |
> |
d = d0; d0 = d1; d1 = d; |
477 |
> |
VCOPY(wpc[1], wp[0]); VCOPY(wpc[0], wp[1]); |
478 |
> |
} |
479 |
> |
if (d0 <= FTINY) { |
480 |
> |
if (d1 <= FTINY) return(0); |
481 |
> |
VSUB(wpc[0], wpc[0], wpc[1]); |
482 |
> |
d = .99*d1/(d1-d0); |
483 |
> |
VSUM(wpc[0], wpc[1], wpc[0], d); |
484 |
> |
} |
485 |
> |
/* get view coordinates and clip to window */ |
486 |
> |
viewloc(ip[0], &odev.v, wpc[0]); |
487 |
> |
viewloc(ip[1], &odev.v, wpc[1]); |
488 |
|
if (!clip(ip[0], ip[1], vmin, vmax)) |
489 |
|
return(0); |
490 |
|
dp[0][0] = ip[0][0]*odev.hres; |
515 |
|
static BYTE gridrgb[3] = {0x0, 0xff, 0xff}; |
516 |
|
unsigned long pixel; |
517 |
|
|
461 |
– |
if (!mapped) |
462 |
– |
return; |
518 |
|
if (ncolors > 0) |
519 |
|
pixel = pixval[get_pixel(gridrgb, xnewcolr)]; |
520 |
|
else |