view3d

diff src/main.c @ 8:5562a637e5aa

load multiple files and concatenate them
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 23 Jan 2012 08:51:59 +0200
parents 58ddd42848f9
children d2e283764fca
line diff
     1.1 --- a/src/main.c	Sat Jan 21 18:20:14 2012 +0200
     1.2 +++ b/src/main.c	Mon Jan 23 08:51:59 2012 +0200
     1.3 @@ -26,7 +26,6 @@
     1.4  void sball_button(int bn, int state);
     1.5  int parse_args(int argc, char **argv);
     1.6  
     1.7 -char *scene_fname;
     1.8  int win_width, win_height;
     1.9  int stereo;
    1.10  int flip_winding;
    1.11 @@ -48,13 +47,9 @@
    1.12  	float ldir[] = {-1, 1, 1, 0};
    1.13  	float dx, dy, dz, diag;
    1.14  
    1.15 +
    1.16  	glutInitWindowSize(800, 600);
    1.17  	glutInit(&argc, argv);
    1.18 -
    1.19 -	if(parse_args(argc, argv) == -1) {
    1.20 -		return 1;
    1.21 -	}
    1.22 -
    1.23  	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE | (stereo ? GLUT_STEREO : 0));
    1.24  	glutCreateWindow("OpenGL 3D viewer");
    1.25  
    1.26 @@ -82,10 +77,16 @@
    1.27  
    1.28  	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, amb);
    1.29  
    1.30 -	if((load_scene(&scn, scene_fname)) == -1) {
    1.31 -		fprintf(stderr, "failed to load: %s\n", scene_fname);
    1.32 +
    1.33 +	init_scene(&scn);
    1.34 +	if(parse_args(argc, argv) == -1) {
    1.35  		return 1;
    1.36  	}
    1.37 +	if(verbose) {
    1.38 +		printf("scene bounds: %.2f %.2f %.2f -> %.2f %.2f %.2f\n", scn.bbox.min[0], scn.bbox.min[1],
    1.39 +				scn.bbox.min[2], scn.bbox.max[0], scn.bbox.max[1], scn.bbox.max[2]);
    1.40 +	}
    1.41 +
    1.42  	dx = scn.bbox.max[0] - scn.bbox.min[0];
    1.43  	dy = scn.bbox.max[1] - scn.bbox.min[1];
    1.44  	dz = scn.bbox.max[2] - scn.bbox.min[2];
    1.45 @@ -352,7 +353,7 @@
    1.46  
    1.47  int parse_args(int argc, char **argv)
    1.48  {
    1.49 -	int i;
    1.50 +	int i, num_loaded = 0;
    1.51  
    1.52  	for(i=1; i<argc; i++) {
    1.53  		if(argv[i][0] == '-') {
    1.54 @@ -375,15 +376,15 @@
    1.55  				goto inval;
    1.56  			}
    1.57  		} else {
    1.58 -			if(scene_fname) {
    1.59 -				fprintf(stderr, "unexpected argument: %s\n", argv[i]);
    1.60 +			if((load_scene(&scn, argv[i])) == -1) {
    1.61 +				fprintf(stderr, "failed to load: %s\n", argv[1]);
    1.62  				return -1;
    1.63  			}
    1.64 -			scene_fname = argv[i];
    1.65 +			num_loaded++;
    1.66  		}
    1.67  	}
    1.68  
    1.69 -	if(!scene_fname) {
    1.70 +	if(num_loaded == 0) {
    1.71  		fprintf(stderr, "you must pass the filename of a scene to open\n");
    1.72  		return -1;
    1.73  	}