mfinegan@uceng.UC.EDU (michael k finegan) (03/31/89)
I just compiled the mtv raytracing package on a 3B2/400 (SYS_V) and decided to display the "balls.pic" test output on a targa 16. It apparently works! For anyone who has a targa, but is lazier than I am, here is a simplistic routine to display mtv output files (assume <= 400x512) compile with targa tools library, and check my coordinate choice ... mfinegan@uceng.uc.edu
mfinegan@uceng.UC.EDU (michael k finegan) (03/31/89)
I just compiled the mtv raytracing package on a 3B2/400 (SYS_V) and
decided to display the "balls.pic" test output on a targa 16. It
apparently works! For anyone who has a targa, but is lazier than I am,
here is a simplistic routine to display mtv output files (assume <= 400x512)
compile with targa tools library, and check my coordinate choice ...
mfinegan@uceng.uc.edu
Sorry - I forgot to include the program!
/*
* Display mtv rendered output image file on targa 16
* copyright (c) Michael K. Finegan, 3/1989
* but do what ever you want with it!
*/
#include <stdio.h>
#include <string.h>
#include "tardev.h"
extern struct TARStruct *targa;
unsigned char pixels[1024*3];
main(argc,argv)
int argc;
char **argv;
{
unsigned x, xmax, y, ymax, R, G, B, color;
FILE *fp, *fopen();
if(GraphInit(-1) == -1) {
printf("unable to initialize targa ...\n");
exit(0);
}
if(argc != 2 || (fp = fopen(argv[1],"rb")) == (FILE *)NULL) {
printf("disp_ray file_name\n");
exit(0);
}
if(fscanf(fp,"%d %d\n",&ymax,&xmax) != 2)
fprintf(stderr,"Error reading rows, cols\n");
else
printf("Assuming %d rows x %d cols\n",ymax,xmax);
for(y=0;y<ymax;y++) {
if(fread(pixels,sizeof(unsigned char),3*xmax,fp) != 3*xmax) {
printf("Error reading row %d\n",y);
exit(0);
}
for(x=0;x<xmax;x++) {
/* truncate to 5 bits/pixel/color - nothing sophisticated */
R = pixels[x*3]/8;
G = pixels[x*3 + 1]/8;
B = pixels[x*3 + 2]/8;
color = (R<<10) | (G<<5) | B;
/* graphics coordinate system? x across, y down ? */
/* assume origin at 400th line, so will display if 400 line mode */
PutPix(&color,x,400-y,-1);
}
}
}