Hi,
I''m trying to print some text to the screen using NeHe''s method of glPrint, and I was wondering if there was a way to wrap the text around to the next line if it goes off the screen.
thanks,
Scott
Email
Website
"If you try and don''t succeed, destroy all evidence that you tried."
print text in opengl and wraparound
It sure can be done, in fact I am about to do this very thing for the project I''m working on. If you''ll notice in NeHe''s glprint function in the glcalllists line he''s got strlen(text). Well that''s the length of the text string right there. now figure out how many you can fit on the screen and have an if statement drop you to the next line if that number is exceeded.
Here''s how I''d do it :
First I''d precalculate how many characters can fit across the screen.
Then in glPrint() I''d divide the string into however many smaller strings it would take to have them all fit.
Then, call glPrint() again from within itself, with a slightly lower y value for each line, with each of the sub-strings instead of the full length one
email
Something kinda sad about
the way that things have come to be.
Desensitized to everything.
What became of subtlety?
--Tool
First I''d precalculate how many characters can fit across the screen.
Then in glPrint() I''d divide the string into however many smaller strings it would take to have them all fit.
Then, call glPrint() again from within itself, with a slightly lower y value for each line, with each of the sub-strings instead of the full length one
Something kinda sad about
the way that things have come to be.
Desensitized to everything.
What became of subtlety?
--Tool
[email=JValentine_13@hotmail.com]contact[/email]
hehe, he was a little faster
email
Something kinda sad about
the way that things have come to be.
Desensitized to everything.
What became of subtlety?
--Tool
Something kinda sad about
the way that things have come to be.
Desensitized to everything.
What became of subtlety?
--Tool
[email=JValentine_13@hotmail.com]contact[/email]
Lol! Thanks and I''ll see what I can do with that.
Thanks again,
Scott
Email
Website
"If you try and don''t succeed, destroy all evidence that you tried."
Thanks again,
Scott
Website
"If you try and don''t succeed, destroy all evidence that you tried."
just thought of something while trying to implement this, the string will have to be parsed for spaces too don''t wanna cut it mid word now do we?
If you really want it nice you have to record where the last space was so you can make the whole word wrap rather than just the letter:
Bad:
Hello, Wo
rld!
Good:
Hello,
World!
Open mouth, insert foot
Bad:
Hello, Wo
rld!
Good:
Hello,
World!
Open mouth, insert foot
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement