bloboland
diff src/main.cc @ 2:1757973feaed
added stereoscopic rendering for no apparent reason
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 16 Dec 2012 00:37:35 +0200 |
parents | cfe68befb7cc |
children | 9021a906c5d3 |
line diff
1.1 --- a/src/main.cc Sat Dec 15 23:43:03 2012 +0200 1.2 +++ b/src/main.cc Sun Dec 16 00:37:35 2012 +0200 1.3 @@ -18,9 +18,11 @@ 1.4 static void spacerot(int x, int y, int z); 1.5 static void spacebut(int bn, int state); 1.6 1.7 -static int win_xsz, win_ysz, centerx, centery; 1.8 +static int centerx, centery; 1.9 static unsigned int prev_msec; 1.10 1.11 +static bool stereo_shift_pressed; 1.12 + 1.13 int main(int argc, char **argv) 1.14 { 1.15 glutInit(&argc, argv); 1.16 @@ -59,6 +61,7 @@ 1.17 { 1.18 unsigned int msec = glutGet(GLUT_ELAPSED_TIME); 1.19 game_iter((msec - prev_msec) / 1000.0); 1.20 + prev_msec = msec; 1.21 1.22 1.23 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 1.24 @@ -101,8 +104,14 @@ 1.25 1.26 static void skeydown(int key, int x, int y) 1.27 { 1.28 - if(key == 27) { 1.29 + switch(key) { 1.30 + case 27: 1.31 exit(0); 1.32 + 1.33 + case 'z': 1.34 + case 'Z': 1.35 + stereo_shift_pressed = true; 1.36 + break; 1.37 } 1.38 1.39 if(key < GAME_MAX_KEYS) { 1.40 @@ -112,6 +121,13 @@ 1.41 1.42 static void skeyup(int key, int x, int y) 1.43 { 1.44 + switch(key) { 1.45 + case 'z': 1.46 + case 'Z': 1.47 + stereo_shift_pressed = false; 1.48 + break; 1.49 + } 1.50 + 1.51 if(key < GAME_MAX_KEYS) { 1.52 keystate[key] = false; 1.53 } 1.54 @@ -155,6 +171,15 @@ 1.55 prev_x = x; 1.56 prev_y = y; 1.57 1.58 + if(stereo_shift_pressed) { 1.59 + if(dy != 0) { 1.60 + stereo_focus_dist += dy * 0.01; 1.61 + stereo_eye_sep = stereo_focus_dist / 30.0; 1.62 + printf("foc: %f, sep: %f\n", stereo_focus_dist, stereo_eye_sep); 1.63 + } 1.64 + return; 1.65 + } 1.66 + 1.67 if(bnstate[0]) { 1.68 game_input_rot((float)dx / win_xsz, (float)dy / win_ysz); 1.69 } 1.70 @@ -162,16 +187,15 @@ 1.71 1.72 static void spacemove(int x, int y, int z) 1.73 { 1.74 - game_input_move(x * 0.1, y * 0.1, z * 0.1); 1.75 + game_input_move(x * 0.0025, y * 0.0025, -z * 0.0025); 1.76 } 1.77 1.78 static void spacerot(int x, int y, int z) 1.79 { 1.80 - game_input_rot(y * 0.1, x * 0.1); 1.81 + game_input_rot(-y * 0.0001, -x * 0.0001); 1.82 } 1.83 1.84 static void spacebut(int bn, int state) 1.85 { 1.86 game_input_shoot(bn); 1.87 } 1.88 -