stereoview

diff src/stereoview.cc @ 2:30c7a5df0523

- added focus distance cmdline argument - changed the code to use the regular henge::Scene when using the zbuffer
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 04 Mar 2011 15:51:03 +0200
parents dc1723a8bf6f
children
line diff
     1.1 --- a/src/stereoview.cc	Fri Mar 04 06:51:16 2011 +0200
     1.2 +++ b/src/stereoview.cc	Fri Mar 04 15:51:03 2011 +0200
     1.3 @@ -28,6 +28,7 @@
     1.4  
     1.5  static bool use_stereo = false;
     1.6  static bool use_zbuf = true;
     1.7 +static float focus_dist = 1.0;
     1.8  
     1.9  static std::list<std::string> scn_fnames;
    1.10  static henge::Scene *scn;
    1.11 @@ -91,7 +92,11 @@
    1.12  		return 1;
    1.13  	}
    1.14  
    1.15 -	scn = new ZScene;
    1.16 +	if(use_zbuf) {
    1.17 +		scn = new henge::Scene;
    1.18 +	} else {
    1.19 +		scn = new ZScene;
    1.20 +	}
    1.21  
    1.22  	std::list<std::string>::iterator it = scn_fnames.begin();
    1.23  	while(it != scn_fnames.end()) {
    1.24 @@ -110,6 +115,7 @@
    1.25  	rend->set_render_mask(henge::REND_ALL & ~henge::REND_CAM);
    1.26  
    1.27  	cam_reset();
    1.28 +	cam_focus_dist(focus_dist);
    1.29  
    1.30  	glutMainLoop();
    1.31  	return 0;
    1.32 @@ -122,6 +128,8 @@
    1.33  
    1.34  static int parse_args(int argc, char **argv)
    1.35  {
    1.36 +	char *endptr;
    1.37 +
    1.38  	for(int i=1; i<argc; i++) {
    1.39  		if(argv[i][0] == '-') {
    1.40  			if(argv[i][2]) {
    1.41 @@ -138,9 +146,19 @@
    1.42  				use_zbuf = false;
    1.43  				break;
    1.44  
    1.45 +			case 'f':
    1.46 +				focus_dist = strtof(argv[++i], &endptr);
    1.47 +				if(endptr == argv[i]) {
    1.48 +					fprintf(stderr, "-f must be followed by the focus distance\n");
    1.49 +					return -1;
    1.50 +				}
    1.51 +				break;
    1.52 +
    1.53  			case 'h':
    1.54  				printf("usage: %s [options]\n", argv[0]);
    1.55  				printf(" -s\tuse stereoscopic rendering\n");
    1.56 +				printf(" -z\tdon't use z-buffer\n");
    1.57 +				printf(" -f <num>\tstereo focus distance\n");
    1.58  				printf(" -h\tprint usage and exit\n");
    1.59  				exit(0);
    1.60  
    1.61 @@ -205,8 +223,6 @@
    1.62  
    1.63  static void keyb(unsigned char key, int x, int y)
    1.64  {
    1.65 -	static float focus_dist = 1.0;
    1.66 -
    1.67  	switch(key) {
    1.68  	case 27:
    1.69  		exit(0);