Search code examples
openglfontsuser-inputglutcin

User Input in OpenGL


So I'm creating a simple game (in this case it's a asteroid clone game) and while i press "Start Game" in my Menu section I get to this window: http://i.imgur.com/BhSRZ50.png Now I want to put my nick in that frame but I have no clue how to do it since std::cin doesnt work... I also heard that there is no user input handling in OpenGL... so in such case how to deal with it? So basicaly I want a blinking bar on the left of that frame which indicates where the writting begins (like in MS Word for example) and a user input handling like cin in console application (the blinking bar is not THAT important :P ). Is there a simple way to do it? For the "please enter your nick" I have used glutBitmapCharacter.


Solution

  • If you are using GLUT, you can create callback functions to handle device/user input.

    For this, I would suggest glutKeyboardFunc, glutKeyboardUpFunc, glutSpecialFunc, and glutSpecialUpFunc. The two keyboard functions handle anything that can be represented by an ascii character. The two special functions handle things like shift, control, and alt. I think that you will find this tutorial helpful.

    Happy Coding!