deepstone

diff src/test.c @ 9:bce78aaafc68

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 26 Nov 2011 03:59:48 +0200
parents c3e0bccd673e
children 059bb38506b3
line diff
     1.1 --- a/src/test.c	Mon Nov 21 12:45:18 2011 +0200
     1.2 +++ b/src/test.c	Sat Nov 26 03:59:48 2011 +0200
     1.3 @@ -53,7 +53,7 @@
     1.4  enum { CUBE, SPHERE, TORUS, NUM_PRIMS };
     1.5  static int prim = SPHERE;
     1.6  static int auto_rotate = 1;
     1.7 -static float cam_theta, cam_phi;
     1.8 +static float cam_theta, cam_phi, cam_zoom = 4.0;
     1.9  
    1.10  static int mx, my;
    1.11  
    1.12 @@ -154,6 +154,7 @@
    1.13  	}
    1.14  
    1.15  	mgl_enable(MGL_CULL_FACE);
    1.16 +	mgl_enable(MGL_DEPTH_TEST);
    1.17  	mgl_enable(MGL_SMOOTH);
    1.18  	mgl_color_range(grad_range - 1);	/* gradient range */
    1.19  
    1.20 @@ -180,6 +181,7 @@
    1.21  {
    1.22  	float angle = get_msec() / 10.0;
    1.23  	mgl_clear(0);
    1.24 +	mgl_clear_depth();
    1.25  
    1.26  	mgl_matrix_mode(MGL_MODELVIEW);
    1.27  	mgl_load_identity();
    1.28 @@ -190,7 +192,7 @@
    1.29  		mgl_rotate(cam_theta, 0, 1, 0);
    1.30  		mgl_rotate(cam_phi, 1, 0, 0);
    1.31  	}
    1.32 -	mgl_translate(0, 0, -4);
    1.33 +	mgl_translate(0, 0, -cam_zoom);
    1.34  
    1.35  	switch(prim) {
    1.36  	case TORUS:
    1.37 @@ -316,13 +318,19 @@
    1.38  	prev_x = x;
    1.39  	prev_y = y;
    1.40  
    1.41 -	if(bnstate) {
    1.42 +	if(bnstate & MOUSE_LEFT) {
    1.43  		cam_theta += dx;
    1.44  		cam_phi += dy;
    1.45  
    1.46  		if(cam_phi > 90) cam_phi = 90;
    1.47  		if(cam_phi < -90) cam_phi = -90;
    1.48  	}
    1.49 +	if(bnstate & MOUSE_RIGHT) {
    1.50 +		cam_zoom += dy * 0.1;
    1.51 +		if(cam_zoom < 0.0) {
    1.52 +			cam_zoom = 0.0;
    1.53 +		}
    1.54 +	}
    1.55  }
    1.56  
    1.57  static void sighandler(int s)