Archived

This topic is now archived and is closed to further replies.

printing text with line breaks

This topic is 5401 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

hi, i''m using more or less nehe''s method for printing text at the moment (by building a display list). i was wondering how i could go about making something like: glPrint("hello\nthere"); output: hello there and not hello(some weird symbol here)there thanks, Scott
------------------------------------------------------------
Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."
------------------------------------------------------------

Share this post


Link to post
Share on other sites
NeHe prepares his font class by creating a disply list recognizing the 256 ascii characters. ''\n'' is not an ascii character, it''s a software character used to determine line breaks.

To accomplish what you desire, you''d have to do this:
glPrint("line 1",0,0);
glPrint("line 2",0,16);

where 16 is the height of your characters.

~Main

==
Colt "MainRoach" McAnlis
Programmer
www.badheat.com/sinewave

Share this post


Link to post
Share on other sites
yeah, that''s about as much as i''ve figured out so far. the reason being is that in my gui i''ve got all the controls i want so far working, however i''d like to have a textbox that is capable of multipe lines. i was hoping to just use one char or string for the entire text box caption, but i couldn''t figure out how to have line breaks (ie: enter being pressed goes to the next line). would it be worthwhile to try having a char or string per each line of text? and just a simple int to hold the number of lines?

thanks,
Scott


------------------------------------------------------------
Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."
------------------------------------------------------------

Share this post


Link to post
Share on other sites
so modify the glPrint method to do a raster line break on every \n character. i assume there''s some loop in the method looping through the characters in the string argument. so when it encounters a \n just have it move the raster down and back to the left the appropriate amounts

-me

Share this post


Link to post
Share on other sites