![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Dec 2006
Posts: 49
Rep Power: 0
![]() |
How to input text in openGL??
I can render and display text just fine, but I am unsure of how to input text such as a name into my openGL program. Normally I would input a text vial the console using:
string lastNameofPlayer; cout << lastNameofPlayer; but obviously this doesnt work with openGL. I know how to register keypresses such as hitting the escape button or the space bar but I am unsure of how I'd enter in a string value for the name of a player. Any Ideas?? ![]() |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Well, in the first place, cout is an output function, not an input function, so you wouldn't input a text via the console using it. The appropriate console function would be: cin >> lastNameofPlayer. I have no idea what you want to do with openGL.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Dec 2006
Posts: 49
Rep Power: 0
![]() |
sorry typo I meant to put cin. Well basically at the startup of my game, you need to input player names such as "John" and "Mike" and I am unsure of how to do this
|
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Well, you're pretty laconic. Are you going to make an input dialog? Have you used openGL? You can do well with wxWidgets without any prior experience, if you want to get your feet wet.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3
![]() |
Ideally google and download a class that will take a string and draw it for you or write your own. One way of doing it (the way i think i did it aages ago) is to load a bitmap of a character map then create a quad and interpolate the texture you apply to the quad to where the char is located on the bitmap.
If your using glut, there maybe some functions that will do this for you. but I'm not sure if there is. google it. What exactly are you using opengl with? |
|
|
|
|
|
#6 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3
![]() |
http://nehe.gamedev.net/data/lessons....asp?lesson=13
tutorial on fonts for you to look at. I can't vouch for it though. |
|
|
|
|
|
#7 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Personally, for INPUTTING text, such as player names, I think you'll be better off making a dialog with an text input control....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#8 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3
![]() |
I'd say creating a text input control would be a wee bit too difficult for him at this stage. Take a look into how you can draw text onto the screen first before you start attempting to make a control.
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
He doesn't want to draw text. He wants to input text. Even with the raw Windows API it's not that difficult. With something like wxWidgets (which is cross platform), or similar, it'll be the easiest part of his job.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#10 |
|
Hobbyist Programmer
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3
![]() |
ah yeah, if you put it that way it would. I was under the impression he was wanting the input to be rendered using openGL as well, sorry.
If you're using glut instead of win32 or wxWidgets, then you may need to look at something like GLUI http://www.cs.unc.edu/~rademach/glui/ I've not used it but its meant to be good. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to detect cursor location and insert text??? | syntax-error | C# | 3 | Jun 30th, 2005 1:42 AM |
| how do i automate text data and input into database? | lionel84 | C# | 0 | Jun 26th, 2005 9:35 PM |