Advertisement Jump to content
Sign in to follow this  
moudy

OpenGL How to get user writing input string in openGl?

This topic is 1834 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need the way for allow users input text by writing (typing) , while users input text they see what's they input when user press enter jump for next line and when user end press on button to finish ?

note: I need user text input without opening a new window etc.

Edited by moudy

Share this post


Link to post
Share on other sites
Advertisement

OpenGL is a graphics library only, and doesn't have (and shouldn't have) any GUI features built-in.

 

If you're using C++, consider using Qt for GUI-based applications.

Here's a screenshot of me using Qt to build an editor alongside my game: (still a work in progress)

cisd.png

 

Qt is for heavily GUI-driven applications, and takes over a great deal of your application. If text entry is really all you want, then Qt is way overkill, and you'd want something smaller like a OpenGL-based in-game GUI library - I don't have personal experience with any of those, but a half-dozen or so of them exist.

Share this post


Link to post
Share on other sites

If you're looking for something with a lot smaller footprint than the Qt suggestion, you can use SDL. You can probably learn all the essentials of SDL in less than a day, and there are plenty of tutorials out there. Text input in SDL is just an event of type SDL_TEXTINPUT. If you need the key's state (down or up), you can track event types SDL_KEYDOWN and SDL_KEYUP instead.

Share this post


Link to post
Share on other sites

 

SDL doesn't have any GUI capabilities, just events.

SDL + SDL_ttf pretty much fits the bill, no?

 

Perhaps! I was reading the OP's request as a LineEdit or TextEdit-style widget (but just not in a Win32-style pop-up modal dialog box).

 

@moudy: Are you looking for something like this:

q676.png

 

Or similar to this:

qeat.png

 

Or something else entirely?

Edited by Servant of the Lord

Share this post


Link to post
Share on other sites

Then you'll probably need to code most of it yourself to fine-tune it to your desires, using OpenGL-based text-renderers.

 

If your game is 2D, I'd suggest SFML 2, but SDL and SDL_ttf (like richardurich mentioned) are excellent as well. You could even use SDL_ttf or SFML to generate OpenGL textures for you that contain text, but the logical interactions and the correct layout will need to be written by your code.

 

Alternatively, you could try a OpenGL-based GUI library (which one, I wouldn't know).

Share this post


Link to post
Share on other sites

SotL already said what he is using for his example screenshot: Qt. If you decide to go down this route (which may not be wise for all types of games) and you aren't familiar with Qt yet then you will have to spend at least a few weeks learning a bit more about Qt. It's a quite massive framework and there is little room for cherry-picking a few pieces out quickly.

 

There are plenty of places to learn about Qt, including the site SotL (and now myself) linked.

Edited by BitMaster

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!