--- ray/src/util/vwrays.c 2005/09/19 04:26:09 3.12 +++ ray/src/util/vwrays.c 2011/08/20 20:57:52 3.16 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: vwrays.c,v 3.12 2005/09/19 04:26:09 greg Exp $"; +static const char RCSid[] = "$Id: vwrays.c,v 3.16 2011/08/20 20:57:52 greg Exp $"; #endif /* * Compute rays corresponding to a given picture or view. @@ -31,6 +31,8 @@ int zfd = -1; int fromstdin = 0; +int unbuffered = 0; + char *progname; @@ -56,9 +58,11 @@ main( break; case 'f': /* float */ putr = putf; + SET_FILE_BINARY(stdout); break; case 'd': /* double */ putr = putd; + SET_FILE_BINARY(stdout); break; default: goto userr; @@ -103,13 +107,16 @@ main( if (argv[i][2] == 'a') pa = atof(argv[++i]); else if (argv[i][2] == 'j') - pj= atof(argv[++i]); + pj = atof(argv[++i]); else goto userr; break; case 'i': /* get pixels from stdin */ fromstdin = 1; break; + case 'u': /* unbuffered output */ + unbuffered = 1; + break; default: goto userr; } @@ -149,7 +156,7 @@ main( exit(0); userr: fprintf(stderr, - "Usage: %s [ -i -f{a|f|d} | -d ] { view opts .. | picture [zbuf] }\n", + "Usage: %s [ -i -u -f{a|f|d} | -d ] { view opts .. | picture [zbuf] }\n", progname); exit(1); } @@ -182,13 +189,6 @@ pix2rays( while (fscanf(fp, "%lf %lf", &px, &py) == 2) { px += .5; py += .5; - if (px < 0 || px >= rs.xr || - py < 0 || py >= rs.yr) { - fprintf(stderr, - "%s: (x,y) pair (%.0f,%.0f) out of range\n", - progname, px, py); - exit(1); - } loc[0] = px/rs.xr; loc[1] = py/rs.yr; if (zfd >= 0) { loc2pix(pp, &rs, loc[0], loc[1]); @@ -216,6 +216,8 @@ pix2rays( rdir[0] *= d; rdir[1] *= d; rdir[2] *= d; } (*putr)(rorg, rdir); + if (unbuffered) + fflush(stdout); } if (!feof(fp)) { fprintf(stderr, "%s: expected px py on input\n", progname);