Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have an OpenGL game and and I want to implement a simple way for the user to enter data/text in an input box. What is the easiest method to do this?

share|improve this question
What are you using for input management? –  thedaian Sep 1 '11 at 11:02
Do you want to have OpenGL controls (EditBox, Label, Button)? –  Krom Stern Sep 1 '11 at 11:28
what is input management? ( im beginner ). for now i just what to get simple Text box or something very simple –  user3689 Sep 1 '11 at 11:49
Input management, as in how are you handling keyboard input from the user. Different libraries handle things differently. –  thedaian Sep 1 '11 at 14:37
its opengl native –  user3689 Sep 3 '11 at 4:42

2 Answers 2

OpenGL is a rendering system. Rendering has nothing to do with getting text input. If you want text input, then you're going to have to use a library or OS system that provides it.

SDL, Allegro, SFML, and most of the other "multimedia" libraries all have some means of getting input from the user. They're also cross-platform, if you're into that sort of thing. Even the "toy" libraries like GLFW and FreeGLUT have ways of getting basic input.

As for the "text box" part, that's going to be more interesting. Generally, if you're making a game, you don't really interact with the native windowing GUI. So you either have to use a specialized GUI library like CeGUI, or you have to write the text box code yourself. I would personally suggest investigating game-GUI libraries, as writing a GUI yourself is not particularly fun.

share|improve this answer
Writing a GUI sounds like a whole lot of fun! Why isn't it fun in your opinion? –  Zolomon Oct 2 '11 at 8:18
The problem with rolling your own GUI system is that it's a pretty complex task and there are almost no tutorials available. –  sarahm Oct 3 '11 at 1:10
@Zolomon: "Fun" in this context would be "making the game." Things that get in the way of making the game, code you have to write just to get to the point where you can write your game, is not really part of "fun". –  Nicol Bolas Oct 3 '11 at 2:06
@NicolBolas Ah, I see! Guess I'm still stuck in the "Engine Phase", craving to know how to implement the unlimited features, that your ideal game could use, from scratch. –  Zolomon Oct 3 '11 at 18:59

I don't know, if you want to use just OpenGL or it's also possible to use other libraries. If you can use others, you can try AntTweakBar - gui library for OGL. I have never used it for text input, but there is also string type for variables, so it should work.

You just create bar, add there variable of type string and set callback. When data are changed, you store them to your own variable. Then you add there button. When user presses it, you will just use stored text to whatever you want.

share|improve this answer
maybe some method to capture the user keystroke , and then showing him which keys was printed? –  user3689 Sep 1 '11 at 13:08
If you have some app, it's possible you want have mapped some actions to key strokes. So this could be unpropriate. –  zacharmarz Sep 1 '11 at 13:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.