08-05-2003, 06:58 PM
I am programming a game and I need to be able to have multiple keys pressed simultaneously activating their respective functions continuously as long as the key is pressed. I also need to use shift and control keys. Is there a way to do this using glut commands? If not, can someone direct me to nonglut code that will do this for me?
Here is an example of how my keyboard functions currently look -
void keypressSpecial (int key, int x, int y)
{
if (key== GLUT_KEY_UP){
cout<<"up"<<endl;
}
if (key== GLUT_KEY_DOWN){
cout<<"down"<<endl;
}
}
void keypressNormal (unsigned char key, int x, int y)
{
if (key==109){ //m
cout<<"test m "<<endl;
}
}
And here is how I call them in main –
glutSpecialFunc(keypressSpecial);
glutKeyboardFunc(keypressNormal);
Whenever I switch press a new key, it stops doing what the key before it did (sort of like having to take your feet off the gas pedal whenever you turn the wheel).
I also don’t understand how to use glutGetModifiers to use shift and control.
Thanks ahead time http://www.opengl.org/discussion_boards/ubb/wink.gif
Here is an example of how my keyboard functions currently look -
void keypressSpecial (int key, int x, int y)
{
if (key== GLUT_KEY_UP){
cout<<"up"<<endl;
}
if (key== GLUT_KEY_DOWN){
cout<<"down"<<endl;
}
}
void keypressNormal (unsigned char key, int x, int y)
{
if (key==109){ //m
cout<<"test m "<<endl;
}
}
And here is how I call them in main –
glutSpecialFunc(keypressSpecial);
glutKeyboardFunc(keypressNormal);
Whenever I switch press a new key, it stops doing what the key before it did (sort of like having to take your feet off the gas pedal whenever you turn the wheel).
I also don’t understand how to use glutGetModifiers to use shift and control.
Thanks ahead time http://www.opengl.org/discussion_boards/ubb/wink.gif