erebus

diff src/main.cc @ 9:d38e13d6063c

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 24 May 2014 17:22:53 +0300
parents e2d9bf168a41
children 506e114b7ca2
line diff
     1.1 --- a/src/main.cc	Sat May 24 06:12:57 2014 +0300
     1.2 +++ b/src/main.cc	Sat May 24 17:22:53 2014 +0300
     1.3 @@ -12,7 +12,11 @@
     1.4  static void display();
     1.5  static void reshape(int x, int y);
     1.6  static void keyb(unsigned char key, int x, int y);
     1.7 +static void keyb_up(unsigned char key, int x, int y);
     1.8  static void mouse(int bn, int st, int x, int y);
     1.9 +static void motion(int x, int y);
    1.10 +static void sball_button(int bn, int st);
    1.11 +static void sball_motion(int x, int y, int z);
    1.12  static int next_pow2(int x);
    1.13  
    1.14  static int width, height, rtex_width, rtex_height;
    1.15 @@ -32,7 +36,11 @@
    1.16  	glutDisplayFunc(display);
    1.17  	glutReshapeFunc(reshape);
    1.18  	glutKeyboardFunc(keyb);
    1.19 +	glutKeyboardUpFunc(keyb_up);
    1.20  	glutMouseFunc(mouse);
    1.21 +	glutMotionFunc(motion);
    1.22 +	glutSpaceballButtonFunc(sball_button);
    1.23 +	glutSpaceballMotionFunc(sball_motion);
    1.24  
    1.25  	if(!init()) {
    1.26  		return 1;
    1.27 @@ -169,10 +177,45 @@
    1.28  		erb_begin_frame(erb, 0);
    1.29  		break;
    1.30  	}
    1.31 +
    1.32 +	if(erb_input_keyboard(key, true)) {
    1.33 +		glutPostRedisplay();
    1.34 +	}
    1.35 +}
    1.36 +
    1.37 +static void keyb_up(unsigned char key, int x, int y)
    1.38 +{
    1.39 +	if(erb_input_keyboard(key, false)) {
    1.40 +		glutPostRedisplay();
    1.41 +	}
    1.42  }
    1.43  
    1.44  static void mouse(int bn, int st, int x, int y)
    1.45  {
    1.46 +	if(erb_input_mouse_button(bn - GLUT_LEFT_BUTTON, st == GLUT_DOWN, x, y)) {
    1.47 +		glutPostRedisplay();
    1.48 +	}
    1.49 +}
    1.50 +
    1.51 +static void motion(int x, int y)
    1.52 +{
    1.53 +	if(erb_input_mouse_move(x, y)) {
    1.54 +		glutPostRedisplay();
    1.55 +	}
    1.56 +}
    1.57 +
    1.58 +static void sball_button(int bn, int state)
    1.59 +{
    1.60 +	if(erb_input_6dof_button(bn, state == GLUT_DOWN)) {
    1.61 +		glutPostRedisplay();
    1.62 +	}
    1.63 +}
    1.64 +
    1.65 +static void sball_motion(int x, int y, int z)
    1.66 +{
    1.67 +	if(erb_input_6dof_motion(x / 65536.0, y / 65536.0, z / 65536.0)) {
    1.68 +		glutPostRedisplay();
    1.69 +	}
    1.70  }
    1.71  
    1.72  static int next_pow2(int x)