#include #include using namespace std; void keyboard(unsigned char key, int x, int y) { cout << "keypress " << char(key) << " at (" << x << ", " << y << ")" << endl; return; } void mouse(int button, int state, int x, int y) { cout << "The " ; switch(button) { case GLUT_LEFT_BUTTON: cout << "LEFT"; break; case GLUT_MIDDLE_BUTTON: cout << "MIDDLE"; break; case GLUT_RIGHT_BUTTON: cout << "RIGHT"; break; default: cout << "UNKNOWN"; } cout << " button was "; switch(state) { case GLUT_UP: cout << "RELEASED"; break; case GLUT_DOWN: cout << "PRESSED"; break; default: cout << "UNKNOWN"; } cout << " at (" << x << ", " << y << ")"<< endl; return; } void spaceBallMove(int x, int y, int z){ cout << "Space Move at " << x << " " << y << " " << z << endl; return; } void spaceBallRotate(int x, int y, int z){ cout << "Space Rotate at " << x << " " << y << " " << z << endl; return; } int main(int argc, char * argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowSize(512, 512); glutCreateWindow("GLUT DEMO"); glutKeyboardFunc(keyboard); glutMouseFunc(mouse); glutSpaceballMotionFunc(spaceBallMove); glutSpaceballRotateFunc(spaceBallRotate); glutMainLoop(); return 0; }