Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

mreiland

glutKeyboardFunc()

This topic is 5153 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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 );
}

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!