#include #include #include #include #include using namespace std; void sbmot(int x, int y, int z) { cout << "Motion " << x << " " << y << " " << z << endl; return; } void sbrot(int x, int y, int z) { cout << "Rotation " << x << " " << y << " " << z << endl; } void sbbut(int bn, int state) { cout << "Button " << bn << " pressed " << endl; } void mouse(int button, int state, int x, int y) { cout << x << " " << y << endl; return; } void keypress(unsigned char key, int x, int y) { cout << "Keypress " << key << " at (" << x << ", " << y << ")" << endl; if (key == 'q') { exit(0); } } int main(int argc, char **argv) { glutInit(&argc, argv); glutInitContextVersion(3, 0); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA); glutInitWindowSize(500, 500); glutInitWindowPosition(100, 100); glutCreateWindow("square.cpp"); glutSpaceballMotionFunc(sbmot); glutSpaceballRotateFunc(sbrot); glutSpaceballButtonFunc(sbbut); glutMouseFunc(mouse); glutKeyboardFunc(keypress); glewExperimental = GL_TRUE; glewInit(); glutMainLoop(); return 0; }