void newimage( /* start a new image */ char *s ) { int newnp = 0; /* # rendering procs arg? */ if (s != NULL) sscanf(s, "%d", &newnp); /* free old image */ freepkids(&ptrunk); /* compute resolution */ hresolu = dev->xsiz; vresolu = dev->ysiz; normaspect(viewaspect(&ourview), &dev->pixaspect, &hresolu, &vresolu); ptrunk.xmin = ptrunk.ymin = pframe.l = pframe.d = 0; ptrunk.xmax = pframe.r = hresolu; ptrunk.ymax = pframe.u = vresolu; pdepth = 0; /* clear device */ (*dev->clear)(hresolu, vresolu); if (newparam) { /* (re)start rendering procs */ if (ray_pnprocs) ray_pclose(0); /* should already be closed */ if (newnp > 0) nproc = newnp; if (nproc > 1) ray_popen(nproc); newparam = 0; } else if ((newnp > 0) & (newnp != nproc)) { if (newnp == 1) /* change # rendering procs */ ray_pclose(0); else if (newnp < ray_pnprocs) ray_pclose(ray_pnprocs - newnp); else ray_popen(newnp - ray_pnprocs); nproc = newnp; } niflush = 0; /* get first value */ paint(&ptrunk); }
void ray_pinit( /* initialize ray-tracing processes */ char *otnm, int nproc ) { if (nobjects > 0) /* close old calculation */ ray_pdone(0); ray_init(otnm); /* load the shared scene */ ray_popen(nproc); /* fork children */ }