Advertisement

print text in opengl and wraparound

Started by October 03, 2001 09:23 PM
7 comments, last by Nibbles 23 years, 4 months ago
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."
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.
Advertisement
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

[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


[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."
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?
Advertisement
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
That is what I meant by parsed for spaces.
i''ll say this i tried to do it and messed up so i''m starting over, hope you guys have better luck at it than me

This topic is closed to new replies.

Advertisement