--- ray/src/hd/rholo4.c 1997/12/11 17:40:04 3.12 +++ ray/src/hd/rholo4.c 1998/12/18 11:56:11 3.23 @@ -1,4 +1,4 @@ -/* Copyright (c) 1997 Silicon Graphics, Inc. */ +/* Copyright (c) 1998 Silicon Graphics, Inc. */ #ifndef lint static char SCCSid[] = "$SunId$ SGI"; @@ -13,9 +13,13 @@ static char SCCSid[] = "$SunId$ SGI"; #include #ifndef HDSUF -#define HDSUF ".hdisp" +#define HDSUF ".hdi" #endif +#ifndef FNONBLK +#define FNONBLK O_NONBLOCK +#endif + static int inp_flags; static int dpd[3]; static FILE *dpout; @@ -24,13 +28,13 @@ static FILE *dpout; disp_open(dname) /* open the named display driver */ char *dname; { - char dpath[128], fd0[8], fd1[8], *cmd[5]; - int i; + char buf[128], fd0[8], fd1[8], *cmd[5], *ofn; + int i, n; /* 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) @@ -39,7 +43,7 @@ char *dname; strcpy(fd0, "-1"); sprintf(fd1, "%d", dup(1)); /* start the display process */ - cmd[0] = dpath; + cmd[0] = buf; cmd[1] = froot; cmd[2] = fd1; cmd[3] = fd0; cmd[4] = NULL; i = open_process(dpd, cmd); @@ -53,9 +57,23 @@ char *dname; if (readinp) close(atoi(fd0)); close(atoi(fd1)); - /* write out hologram grids */ - for (i = 0; hdlist[i] != NULL; i++) - disp_result(DS_ADDHOLO, sizeof(HDGRID), (char *)hdlist[i]); + /* check if outside */ + if (vdef(OBSTRUCTIONS) && vbool(OBSTRUCTIONS)) + disp_result(DS_OUTSECT, 0, NULL); + /* send eye separation if specified */ + if (vdef(EYESEP)) { + sprintf(buf, "%.9e", vflt(EYESEP)); + disp_result(DS_EYESEP, strlen(buf)+1, buf); + } + /* write out hologram grids & octrees */ + for (i = 0; hdlist[i] != NULL; i++) { + bcopy((char *)hdlist[i], buf, sizeof(HDGRID)); + n = vdef(OSECTION); + ofn = i 0) + done_rtrace(); + else + error(WARNING, "no rtrace process to kill"); + break; + case DR_RESTART: /* restart computation process(es) */ + if (msg.nbytes) + error(INTERNAL, "bad DR_RESTART from display process"); + if (ncprocs > nprocs) + new_rtrace(); + else if (nprocs > 0) + error(WARNING, "rtrace already runnning"); + else + error(WARNING, "holodeck not open for writing"); + break; + case DR_CLOBBER: /* clobber holodeck */ + if (msg.nbytes) + error(INTERNAL, "bad DR_CLOBBER from display process"); + if (!force || !ncprocs) + error(WARNING, "request to clobber holodeck denied"); + else { + error(WARNING, "clobbering holodeck contents"); + hdclobber(NULL); + } + break; case DR_SHUTDOWN: /* shut down program */ if (msg.nbytes) error(INTERNAL, "bad DR_SHUTDOWN from display process"); @@ -171,6 +233,7 @@ disp_close() /* close our display process */ if (dpout == NULL) return(-1); + myeye.rng = 0; disp_result(DS_SHUTDOWN, 0, NULL); fclose(dpout); dpout = NULL; @@ -183,7 +246,11 @@ int type, nbytes; char *p; { MSGHEAD msg; - + /* consistency checks */ +#ifdef DEBUG + if (nbytes < 0 || nbytes > 0 & p == NULL) + error(CONSISTENCY, "bad buffer handed to disp_result"); +#endif if (dpout == NULL) return; msg.type = type;