Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 6th, 2007, 6:02 PM   #1
csrocker101
Programmer
 
Join Date: Dec 2006
Posts: 49
Rep Power: 0 csrocker101 is on a distinguished road
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??
csrocker101 is offline   Reply With Quote
Old May 6th, 2007, 6:22 PM   #2
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old May 6th, 2007, 6:25 PM   #3
csrocker101
Programmer
 
Join Date: Dec 2006
Posts: 49
Rep Power: 0 csrocker101 is on a distinguished road
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
csrocker101 is offline   Reply With Quote
Old May 6th, 2007, 6:33 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old May 6th, 2007, 7:50 PM   #5
Seif
Hobbyist Programmer
 
Seif's Avatar
 
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3 Seif is on a distinguished road
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?
Seif is offline   Reply With Quote
Old May 6th, 2007, 8:02 PM   #6
Seif
Hobbyist Programmer
 
Seif's Avatar
 
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3 Seif is on a distinguished road
http://nehe.gamedev.net/data/lessons....asp?lesson=13

tutorial on fonts for you to look at. I can't vouch for it though.
Seif is offline   Reply With Quote
Old May 6th, 2007, 9:37 PM   #7
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old May 6th, 2007, 11:25 PM   #8
Seif
Hobbyist Programmer
 
Seif's Avatar
 
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3 Seif is on a distinguished road
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.
Seif is offline   Reply With Quote
Old May 6th, 2007, 11:48 PM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old May 7th, 2007, 9:54 AM   #10
Seif
Hobbyist Programmer
 
Seif's Avatar
 
Join Date: Jan 2006
Location: UK
Posts: 215
Rep Power: 3 Seif is on a distinguished road
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.
Seif is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:21 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC