1 |
< |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
1 |
> |
/* Copyright (c) 1999 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ SGI"; |
16 |
|
#define HDSUF ".hdi" |
17 |
|
#endif |
18 |
|
|
19 |
+ |
#ifndef FNONBLK |
20 |
+ |
#define FNONBLK O_NONBLOCK |
21 |
+ |
#endif |
22 |
+ |
|
23 |
|
static int inp_flags; |
24 |
|
static int dpd[3]; |
25 |
|
static FILE *dpout; |
28 |
|
disp_open(dname) /* open the named display driver */ |
29 |
|
char *dname; |
30 |
|
{ |
31 |
< |
char dpath[128], fd0[8], fd1[8], *cmd[5]; |
32 |
< |
int i; |
31 |
> |
char buf[sizeof(HDGRID)+512], fd0[8], fd1[8], *cmd[5], *sfn; |
32 |
> |
int i, n, len; |
33 |
|
/* get full display program name */ |
34 |
|
#ifdef DEVPATH |
35 |
< |
sprintf(dpath, "%s/%s%s", DEVPATH, dname, HDSUF); |
35 |
> |
sprintf(buf, "%s/%s%s", DEVPATH, dname, HDSUF); |
36 |
|
#else |
37 |
< |
sprintf(dpath, "dev/%s%s", dname, HDSUF); |
37 |
> |
sprintf(buf, "dev/%s%s", dname, HDSUF); |
38 |
|
#endif |
39 |
|
/* dup stdin and stdout */ |
40 |
|
if (readinp) |
43 |
|
strcpy(fd0, "-1"); |
44 |
|
sprintf(fd1, "%d", dup(1)); |
45 |
|
/* start the display process */ |
46 |
< |
cmd[0] = dpath; |
46 |
> |
cmd[0] = buf; |
47 |
|
cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; |
48 |
|
cmd[4] = NULL; |
49 |
|
i = open_process(dpd, cmd); |
62 |
|
disp_result(DS_OUTSECT, 0, NULL); |
63 |
|
/* send eye separation if specified */ |
64 |
|
if (vdef(EYESEP)) { |
65 |
< |
char fbuf[32]; |
66 |
< |
sprintf(fbuf, "%.9e", vflt(EYESEP)); |
63 |
< |
disp_result(DS_EYESEP, strlen(fbuf)+1, fbuf); |
65 |
> |
sprintf(buf, "%.9e", vflt(EYESEP)); |
66 |
> |
disp_result(DS_EYESEP, strlen(buf)+1, buf); |
67 |
|
} |
68 |
< |
/* write out hologram grids */ |
69 |
< |
for (i = 0; hdlist[i] != NULL; i++) |
70 |
< |
disp_result(DS_ADDHOLO, sizeof(HDGRID), (char *)hdlist[i]); |
68 |
> |
/* write out hologram grids & octrees */ |
69 |
> |
for (i = 0; hdlist[i] != NULL; i++) { |
70 |
> |
bcopy((char *)hdlist[i], buf, sizeof(HDGRID)); |
71 |
> |
len = sizeof(HDGRID); |
72 |
> |
n = vdef(GEOMETRY); |
73 |
> |
sfn = i<n ? nvalue(GEOMETRY,i) : |
74 |
> |
n ? nvalue(GEOMETRY,n-1) : vval(OCTREE); |
75 |
> |
strcpy(buf+len, sfn); |
76 |
> |
len += strlen(sfn) + 1; |
77 |
> |
n = vdef(PORTS); |
78 |
> |
sfn = i<n ? nvalue(PORTS,i) : n ? nvalue(PORTS,n-1) : ""; |
79 |
> |
strcpy(buf+len, sfn); |
80 |
> |
len += strlen(sfn) + 1; |
81 |
> |
disp_result(DS_ADDHOLO, len, buf); |
82 |
> |
} |
83 |
|
disp_flush(); |
84 |
|
} |
85 |
|
|
174 |
|
error(INTERNAL, "bad DR_DELSET from display process"); |
175 |
|
bundle_set(BS_DEL, (PACKHEAD *)buf, msg.nbytes/sizeof(PACKHEAD)); |
176 |
|
break; |
177 |
+ |
case DR_VIEWPOINT: /* set target eye position */ |
178 |
+ |
if (msg.nbytes != sizeof(VIEWPOINT)) |
179 |
+ |
error(INTERNAL, "bad DR_VIEWPOINT from display process"); |
180 |
+ |
copystruct(&myeye, (VIEWPOINT *)buf); |
181 |
+ |
break; |
182 |
|
case DR_ATTEN: /* block for priority request */ |
183 |
|
if (msg.nbytes) |
184 |
|
error(INTERNAL, "bad DR_ATTEN from display process"); |
239 |
|
|
240 |
|
if (dpout == NULL) |
241 |
|
return(-1); |
242 |
+ |
myeye.rng = 0; |
243 |
|
disp_result(DS_SHUTDOWN, 0, NULL); |
244 |
|
fclose(dpout); |
245 |
|
dpout = NULL; |