detect space bar release

Started by
4 comments, last by Viks 14 years, 2 months ago
After pressing space bar for some time and releasing it, is there a way in OpenGL to detect that the space bar has been released?
Advertisement
OpenGL is a graphics library, it has no support for keyboard input at all.

What platform are you running on? Do you already have a library to handle input?
OpenGL handles graphics. You need an input API.

On Win32, for example, you could use the WM_KEYUP message. In .Net, you could use a form's KeyUp event. It really depends on what language and libraries you are using.
Quote:Original post by Codeka
OpenGL is a graphics library, it has no support for keyboard input at all.

What platform are you running on? Do you already have a library to handle input?


I am using Visual Studio C++ 2008. For input, I am using glutKeyboardFunc() to capture a space bar hit (detects an ASCII value of 32 if input is through the space bar), but the problem is when do I find out the user is not pressing the space bar anymore?

Let me be a little more specific here. I am developing a golf game in which space bar is provided to the user as an input to provide the force with which the ball is hit. Now, the user has to press the space bar if he wants to increase the force. The moment he/she releases the space bar, my program will have to hit the ball with the force provided by the user, which means, I need to find out, when the user actually released the space bar, so that I can grab those values and calculate the necessary vectors.
Quote:I am using Visual Studio C++ 2008. For input, I am using glutKeyboardFunc() to capture a space bar hit (detects an ASCII value of 32 if input is through the space bar), but the problem is when do I find out the user is not pressing the space bar anymore?

Let me be a little more specific here. I am developing a golf game in which space bar is provided to the user as an input to provide the force with which the ball is hit. Now, the user has to press the space bar if he wants to increase the force. The moment he/she releases the space bar, my program will have to hit the ball with the force provided by the user, which means, I need to find out, when the user actually released the space bar, so that I can grab those values and calculate the necessary vectors.
A Google search for 'glut key release' led me here (first hit). In particular, look here and here.
Bingo, jyk!! glutKeyboardUpFunc() was the one I was looking for. I had looked at the GLUT library before. It's been like a Bible to me. In fact, I am using glutKeyboardFunc() in my code. But I am not sure how I missed glutKeyboardUpFunc(). Many thanks, for the help!!

This topic is closed to new replies.

Advertisement