PDA

View Full Version : glutKeyboardFunc



littledevore
10-09-2001, 02:49 PM
Does anyone know a page, or know where some sample code is that I can learn more about the keyboard function. I can't seem to get it to work and I am going on what I remember...so it's not going very well. Thanks.

JLawson
10-09-2001, 06:55 PM
Don't worry, I'm an oGL newbie, so this is probably wrong..yay~!

The glutKeyboardFunc's argument is a function, like processKeys... Check out this sample code, and see if you learn by example:

void processKeys(unsigned char key, int x, int y) {

switch(key){
case 27: exit(0); break;
case GLUT_KEY_LEFT: angle-=2.1; break;
case GLUT_KEY_RIGHT: angle+=2.1; break;
}
}

void main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(320,320);
glutCreateWindow("Hello World!");
glutKeyboardFunc(processKeys);
glutMainLoop();
}