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

Comparing ray/src/hd/rholo.c (file contents):
Revision 3.3 by gregl, Fri Oct 31 15:49:23 1997 UTC vs.
Revision 3.7 by gregl, Thu Nov 6 16:11:48 1997 UTC

# Line 127 | Line 127 | initrholo()                    /* get our holodeck running */
127   {
128          extern int      global_packet();
129          register int    i;
130 <                                                /* check output device */
131 <        if (outdev != NULL)
132 <                open_display(outdev);
130 >
131 >        if (outdev != NULL)                     /* open output device */
132 >                disp_open(outdev);
133          else if (ncprocs > 0)                   /* else use global ray feed */
134                  init_global();
135                                                  /* record end time */
# Line 138 | Line 138 | initrholo()                    /* get our holodeck running */
138          else
139                  endtime = starttime + vflt(TIME)*3600.;
140                                                  /* set up memory cache */
141 <        hdcachesize = 1024.*1024.*vflt(CACHE);
141 >        if (outdev == NULL)
142 >                hdcachesize = 0;        /* manual flushing */
143 >        else if (vdef(CACHE))
144 >                hdcachesize = 1024.*1024.*vflt(CACHE);
145                                                  /* open report file */
146          if (vdef(REPORT)) {
147                  register char   *s = sskip2(vval(REPORT), 1);
# Line 187 | Line 190 | rholo()                                /* holodeck main loop */
190          register PACKET *p;
191          time_t  t;
192          long    l;
193 <                                        /* check display */
194 <        if (outdev != NULL && !disp_check(idle))
195 <                return(0);
193 >
194 >        if (outdev != NULL)             /* check display */
195 >                if (!disp_check(idle))
196 >                        return(0);
197                                          /* display only? */
198          if (ncprocs <= 0)
199                  return(1);
# Line 294 | Line 298 | register HDGRID        *gp;
298                  vval(DISKSPACE) = "100";
299                  vdef(DISKSPACE)++;
300          }
297        if (!vdef(CACHE)) {
298                sprintf(errmsg,
299                        "no %s setting, assuming 10 Mbytes available",
300                                vnam(CACHE));
301                error(WARNING, errmsg);
302                vval(CACHE) = "10";
303                vdef(CACHE)++;
304        }
301          if (!vdef(OBSTRUCTIONS)) {
302                  vval(OBSTRUCTIONS) = "T";
303                  vdef(OBSTRUCTIONS)++;
# Line 367 | Line 363 | loadholo()                     /* start loading a holodeck from fname */
363   {
364          FILE    *fp;
365          long    endloc;
366 <                                        /* open input file */
367 <        if ((fp = fopen(hdkfile, "r+")) == NULL) {
368 <                sprintf(errmsg, "cannot open \"%s\" for appending", hdkfile);
366 >                                        /* open holodeck file */
367 >        if ((fp = fopen(hdkfile, ncprocs>0 ? "r+" : "r")) == NULL) {
368 >                sprintf(errmsg, "cannot open \"%s\" for %s", hdkfile,
369 >                                ncprocs>0 ? "appending" : "reading");
370                  error(SYSTEM, errmsg);
371          }
372                                          /* load variables from header */
# Line 392 | Line 389 | loadholo()                     /* start loading a holodeck from fname */
389   done_packets(pl)                /* handle finished packets */
390   PACKET  *pl;
391   {
392 +        static int      nunflushed = 0;
393          register PACKET *p;
394  
395          while (pl != NULL) {
# Line 401 | Line 399 | PACKET *pl;
399                                  (char *)hdnewrays(hdlist[p->hd],p->bi,p->nr),
400                                  p->nr*sizeof(RAYVAL));
401                          if (outdev != NULL)     /* display it */
402 <                                disp_packet(p);
402 >                                disp_packet((PACKHEAD *)p);
403 >                        else
404 >                                nunflushed += p->nr;
405 >                        nraysdone += p->nr;
406 >                        npacksdone++;
407                  }
406                nraysdone += p->nr;
407                npacksdone++;
408                  p->nr = 0;                      /* push onto free list */
409                  p->next = freepacks;
410                  freepacks = p;
411          }
412 +        if (nunflushed >= 256*RPACKSIZ) {
413 +                hdflush(NULL);                  /* flush holodeck buffers */
414 +                nunflushed = 0;
415 +        }
416   }
417  
418  
# Line 514 | Line 518 | int    ec;
518   {
519          int     status = 0;
520  
521 +        if (outdev != NULL)             /* close display */
522 +                disp_close();
523          if (hdlist[0] != NULL) {        /* flush holodeck */
524                  if (ncprocs > 0) {
525                          done_packets(flush_queue());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines