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?
|
|
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. |
|||||||||||
|
|
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. |
|||||
|