--- ray/src/hd/rholo4.c 1998/10/22 08:47:40 3.21 +++ ray/src/hd/rholo4.c 2003/02/22 02:07:25 3.28 @@ -1,9 +1,6 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rholo4.c,v 3.28 2003/02/22 02:07:25 greg Exp $"; #endif - /* * Holodeck display process communication */ @@ -13,8 +10,11 @@ static char SCCSid[] = "$SunId$ SGI"; #include #ifndef HDSUF -#define HDSUF ".hdi" +#define HDSUF ".hdi" #endif +#ifndef SLAVENAME +#define SLAVENAME "slave" +#endif #ifndef FNONBLK #define FNONBLK O_NONBLOCK @@ -28,47 +28,65 @@ static FILE *dpout; disp_open(dname) /* open the named display driver */ char *dname; { - char dpath[128], fd0[8], fd1[8], *cmd[5]; - int i; - /* get full display program name */ + char buf[sizeof(HDGRID)+512], fd0[8], fd1[8], *cmd[5], *sfn; + int i, n, len; + + if (!strcmp(dname, SLAVENAME)) { + dpd[0] = 0; /* read from stdin */ + dpout = stdout; /* write to stdout */ + dpd[2] = -1; /* we're the slave process */ + } else { + /* get full display program name */ #ifdef DEVPATH - sprintf(dpath, "%s/%s%s", DEVPATH, dname, HDSUF); + sprintf(buf, "%s/%s%s", DEVPATH, dname, HDSUF); #else - sprintf(dpath, "dev/%s%s", dname, HDSUF); + sprintf(buf, "dev/%s%s", dname, HDSUF); #endif - /* dup stdin and stdout */ - if (readinp) - sprintf(fd0, "%d", dup(0)); - else - strcpy(fd0, "-1"); - sprintf(fd1, "%d", dup(1)); - /* start the display process */ - cmd[0] = dpath; - cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; - cmd[4] = NULL; - i = open_process(dpd, cmd); - if (i <= 0) - error(USER, "cannot start display process"); - if ((dpout = fdopen(dpd[1], "w")) == NULL) - error(SYSTEM, "cannot associate FILE with display pipe"); + /* dup stdin and stdout */ + if (readinp) + sprintf(fd0, "%d", dup(0)); + else + strcpy(fd0, "-1"); + sprintf(fd1, "%d", dup(1)); + /* start the display process */ + cmd[0] = buf; + cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; + cmd[4] = NULL; + i = open_process(dpd, cmd); + if (i <= 0) + error(USER, "cannot start display process"); + if ((dpout = fdopen(dpd[1], "w")) == NULL) + error(SYSTEM, "problem opening display pipe"); + /* close dup'ed stdin and stdout */ + if (readinp) + close(atoi(fd0)); + close(atoi(fd1)); + } dpd[1] = -1; /* causes ignored error in close_process() */ inp_flags = 0; - /* close dup'ed stdin and stdout */ - if (readinp) - close(atoi(fd0)); - close(atoi(fd1)); /* check if outside */ if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS)) disp_result(DS_OUTSECT, 0, NULL); /* send eye separation if specified */ if (vdef(EYESEP)) { - char fbuf[32]; - sprintf(fbuf, "%.9e", vflt(EYESEP)); - disp_result(DS_EYESEP, strlen(fbuf)+1, fbuf); + sprintf(buf, "%.9e", vflt(EYESEP)); + disp_result(DS_EYESEP, strlen(buf)+1, buf); } - /* write out hologram grids */ - for (i = 0; hdlist[i] != NULL; i++) - disp_result(DS_ADDHOLO, sizeof(HDGRID), (char *)hdlist[i]); + /* write out hologram grids & octrees */ + for (i = 0; hdlist[i] != NULL; i++) { + bcopy((char *)hdlist[i], buf, sizeof(HDGRID)); + len = sizeof(HDGRID); + n = vdef(GEOMETRY); + sfn = i