Keyboardfunc

Hi guys,

im a few month into opengl now and im working on a small 2 player game. the first player moves with awsd, the 2nd with ijkl
and im using the glutkeyboardfunc().
my problem is now that it isnt possible to press 2 buttons simultaneous. so at the moment, if you move, and the other player presses a button you get interrupted.
how can i make it possible that both players have full controll and dont get interuppted by the other?

any ideas to solve that problem?

big thx for your help!

Use GLFW instead of GLUT. Really.

Avoid using GLUT if you are going to be making a game.

I’m working on Windows so I use the Win32 message pump directly to get all the key presses. You have a lot more control this way.

You might try Or-ing the inputs into a single key-case and perform the appropriate operations on each player’s entity separately.

this way it works no matter how many inputs simultaneously.

If you dont mind using win32 i would recommend it any day.

sry i dont understand…

here is a short preview of my keyboard method



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

 switch (key) {
 
     case ' ':
     player1.shoot();
     break;

     case 'a':
     player1.rotateY(+3);
     break;

     case 'd':
     player1.rotateY(-3);
     break;

     //player 2
     case '.':
     player2.shoot();
     break;

     case 'h':
     player2.rotateY(+3);
     break;

     case 'k':
     player2.rotateY(-3);
     break;

     
     etc....
  }
}


so how should i change that?

if there is no other way, i will try it with glfw. but im using many glut operations, so it will cost me much time to change all my already written code!