glutKeyboardFunc()

Started by
4 comments, last by mreiland 20 years ago
I''ve decided to sit down and write a tetris like clone just to learn OpenGL. I decided to use GLUT to handle my windowing stuff since I prefer cross platform( I run Gentoo linux as my main Desktop OS), and I''m concentrating on learning. I''ve got it displaying, and moving the tetris figures down, but I can''t seem to get my keyboard callback function to work. glut just isn''t calling it when I press any of the keys, and I have no idea why. I''ve verified that I''m not trapping the program execution outside of glut, and all of my other callback''s are firing, just not my keyboard callback. Is there something that I''m missing that I don''t know about? I''d really appreciate it anyone''s suggestions on what to look into, as this has me a bit miffed. PS I''m developing this on an up to date Gentoo Linux box with an NVidia GeForce FX 5200.
Advertisement
Could you post your callback procedure?
Sure. It''s not much more than a stub at the moment, but here it is

Keep in mind that I''m invoking this via the console, so standard output will be my console(for the single cout statement).


void tetris::KeyboardEvent(GLubyte pKey, GLint pX, GLint pY ){	std::cout << pKey << " " << pX << " " << pY << std::endl;	switch( pKey )	{		case GLUT_KEY_RIGHT:			break;		case GLUT_KEY_LEFT:			break;		case GLUT_KEY_UP:			tetrisFigure->FlipRight();			break;		case GLUT_KEY_DOWN:			break;		default:			break;	}} 




Here''s my function that does the actual callback initializations

void tetris::GLUTCallbackInit(){	glutKeyboardFunc( KeyboardEvent );	glutDisplayFunc( Draw );		glutIdleFunc( MainLoop );	glutTimerFunc( timeInterval, IncrementFigure, timeInterval );} 
bump
It looks fine to me.

You''re saying the function does not get called at all...yet there you have it initializing the callback function.
I know this is going to seem like a stupid question, but it's the only thing I can think of off the top of my head. You are calling glutMainLoop() somewhere, right? I mean, rather than looping manually?

EDIT: Nevermind, you said all your other callbacks are working properly. Hm...

[edited by - null_void on April 13, 2004 4:47:30 PM]

This topic is closed to new replies.

Advertisement