ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/hd/rhdisp.c
(Generate patch)

Comparing ray/src/hd/rhdisp.c (file contents):
Revision 3.36 by gwlarson, Thu Dec 10 10:45:54 1998 UTC vs.
Revision 3.42 by gwlarson, Thu Jul 29 15:38:40 1999 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1998 Silicon Graphics, Inc. */
1 > /* Copyright (c) 1999 Silicon Graphics, Inc. */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ SGI";
# Line 22 | Line 22 | static char SCCSid[] = "$SunId$ SGI";
22   #define FSIZDEF         0.125   /* default focus frame size */
23   #endif
24  
25 + #ifdef linux
26 + #define fbufcnt(f)      ((f)->_IO_read_end - (f)->_IO_read_ptr)
27 + #else
28 + #define fbufcnt(f)      ((f)->_cnt)
29 + #endif
30 +
31   HOLO    *hdlist[HDMAX+1];       /* global holodeck list */
32  
33 + char    *hdgfn[HDMAX];          /* holodeck section geometry list */
34 + char    *hdpfn[HDMAX];          /* section portal list */
35 +
36   char    cmdlist[DC_NCMDS][8] = DC_INIT;
37  
38   int     imm_mode = 0;           /* bundles are being delivered immediately */
# Line 37 | Line 46 | char   *progname;              /* global argv[0] */
46   FILE    *sstdin, *sstdout;      /* server's standard input and output */
47  
48   #ifdef DEBUG
40 #include <sys/types.h>
49   extern time_t   time();
50   static time_t   tmodesw;
51   static time_t   timm, tadd;
# Line 88 | Line 96 | char   *argv[];
96                          inp = dev_input();
97                          if (inp & DFL(DC_SETVIEW))
98                                  new_view(&odev.v);
99 +                        else if (inp & DFL(DC_LASTVIEW))
100 +                                new_view(NULL);
101 +                        if (inp & DFL(DC_REDRAW))
102 +                                imm_mode = beam_sync(1) > 0;
103                          if (inp & DFL(DC_GETVIEW))
104                                  printview();
93                        if (inp & DFL(DC_LASTVIEW))
94                                new_view(NULL);
105                          if (inp & DFL(DC_FOCUS))
106                                  set_focus(odev_args);
107                          if (inp & DFL(DC_KILL)) {
# Line 110 | Line 120 | char   *argv[];
120                          }
121                          if (inp & DFL(DC_PAUSE))
122                                  pause = 1;
113                        if (inp & DFL(DC_REDRAW))
114                                imm_mode = beam_sync(1) > 0;
123                          if (inp & DFL(DC_QUIT))
124                                  serv_request(DR_SHUTDOWN, 0, NULL);
125                  }
# Line 152 | Line 160 | disp_wait()                    /* wait for more input */
160          int     n;
161          register int    i;
162                                  /* see if we can avoid select call */
163 +        if (hdlist[0] == NULL)
164 +                return(RDY_SRV);        /* initialize first */
165          flgs = 0;               /* flag what's ready already */
166 <        if (imm_mode || stdin->_cnt > 0)
166 >        if (imm_mode || fbufcnt(stdin) > 0)
167                  flgs |= RDY_SRV;
168 <        if (sstdin != NULL && sstdin->_cnt > 0)
168 >        if (sstdin != NULL && fbufcnt(sstdin) > 0)
169                  flgs |= RDY_SIN;
170          if (odev.inpready)
171                  flgs |= RDY_DEV;
# Line 193 | Line 203 | disp_wait()                    /* wait for more input */
203   }
204  
205  
206 < add_holo(hdg)                   /* register a new holodeck section */
206 > add_holo(hdg, gfn, pfn)         /* register a new holodeck section */
207   HDGRID  *hdg;
208 + char    *gfn, *pfn;
209   {
210          VIEW    nv;
211          double  d;
# Line 209 | Line 220 | HDGRID *hdg;
220                  error(SYSTEM, "out of memory in add_holo");
221          bcopy((char *)hdg, (char *)hdlist[hd], sizeof(HDGRID));
222          hdcompgrid(hdlist[hd]);
223 +        hdgfn[hd] = savestr(gfn);
224 +        hdpfn[hd] = pfn && *pfn ? savestr(pfn) : (char *)NULL;
225          if (hd)
226                  return;
227                                          /* set initial viewpoint */
# Line 264 | Line 277 | register VIEW  *v;
277          static unsigned nhist;
278          VIEW    *dv;
279          int     i, res[2];
280 +        int2    *slist;
281          char    *err;
282                                  /* restore previous view? */
283          if (v == NULL) {
# Line 279 | Line 293 | again:
293                  error(COMMAND, err);
294                  return;
295          }
296 +        if (!dev_view(v))       /* notify display driver */
297 +                goto again;
298          if (v->type == VT_PAR) {
299                  error(COMMAND, "cannot handle parallel views");
300                  return;
301          }
302 <        if (!dev_view(v))       /* notify display driver */
303 <                goto again;
304 <        dev_flush();            /* update screen */
289 <        beam_init(0);           /* compute new beam set */
290 <        for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++)
291 <                if (!beam_view(dv, res[0], res[1])) {
302 >        beam_init(odev.firstuse);       /* compute new beam set */
303 >        for (i = 0; (dv = dev_auxview(i, res)) != NULL; i++) {
304 >                if ((slist = beam_view(dv, res[0], res[1])) == NULL) {
305                          if (!nhist) {
306                                  error(COMMAND, "invalid starting view");
307                                  return;
308                          }
309                          copystruct(v, viewhist + ((nhist-1)%VIEWHISTLEN));
310 <                        goto again;
311 <                }      
310 >                        goto again;     /* poss. overloading dev_section()? */
311 >                }
312 >                DCHECK(*slist < 0, WARNING, "no visible sections in new_view");
313 >                for ( ; *slist >= 0; slist++)
314 >                        dev_section(hdgfn[*slist], hdpfn[*slist]);
315 >        }
316 >        dev_section(NULL,NULL); /* end section list */
317 >        dev_flush();            /* update display */
318                                  /* update server */
319 <        imm_mode = beam_sync(0) > 0;
319 >        imm_mode = beam_sync(odev.firstuse) > 0;
320                                  /* record new view */
321          if (v < viewhist || v >= viewhist+VIEWHISTLEN) {
322                  copystruct(viewhist + (nhist%VIEWHISTLEN), v);
# Line 477 | Line 496 | serv_result()                  /* get next server result and process
496                  disp_bundle((PACKHEAD *)buf);
497                  break;
498          case DS_ADDHOLO:
499 <                if (msg.nbytes != sizeof(HDGRID))
499 >                if (msg.nbytes < sizeof(HDGRID)+2)
500                          error(INTERNAL, "bad holodeck record from server");
501 <                add_holo((HDGRID *)buf);
501 >                add_holo((HDGRID *)buf, buf+sizeof(HDGRID),
502 >                        buf+sizeof(HDGRID)+strlen(buf+sizeof(HDGRID))+1);
503                  break;
504          case DS_OUTSECT:
505                  do_outside = 1;
# Line 490 | Line 510 | serv_result()                  /* get next server result and process
510                  break;
511          case DS_STARTIMM:
512          case DS_ENDIMM:
513 +                if (!(imm_mode = msg.type==DS_STARTIMM))
514 +                        dev_flush();
515   #ifdef DEBUG
516                  {
517                          time_t  tnow = time(NULL);
# Line 498 | Line 520 | serv_result()                  /* get next server result and process
520                          tmodesw = tnow;
521                  }
522   #endif
501                if (!(imm_mode = msg.type==DS_STARTIMM))
502                        dev_flush();
523                  goto noargs;
524          case DS_ACKNOW:
525          case DS_SHUTDOWN:
# Line 529 | Line 549 | char   *p;
549          MSGHEAD msg;
550          int     m;
551                                  /* consistency checks */
552 < #ifdef DEBUG
553 <        if (nbytes < 0 || nbytes > 0 & p == NULL)
534 <                error(CONSISTENCY, "bad buffer handed to serv_request");
535 < #endif
552 >        DCHECK(nbytes < 0 || nbytes > 0 & p == NULL,
553 >                        CONSISTENCY, "bad buffer handed to serv_request");
554                                  /* get server's attention for big request */
555          if (nbytes >= BIGREQSIZ-sizeof(MSGHEAD)) {
556                  serv_request(DR_ATTEN, 0, NULL);
# Line 572 | Line 590 | register char  *s;
590   quit(code)                      /* clean up and exit */
591   int     code;
592   {
593 +        if (code)
594 +                exit(code);
595          if (odev.v.type)
596                  dev_close();
597 <        exit(code);
597 >        exit(0);
598   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines