View Full Version : tutorials on text
urika
09-03-2003, 08:29 AM
can anyone reffer me to good tutorial for showing 2d text on openGL
on MFC??
i want to show text with my other objects :huh:
baldurk
09-03-2003, 11:16 AM
hmm. OpenGL + MFC seems a strange combination, but I doubt you'd need or even want to use MFC for outputting text. You can either create a 3D font, but that's platform specific, and kinda useless unless you want 3D text for a reason. The best way is to have a font texture, and display quads with the texture co-ords correctly set up to only have one character covering them.
1. take the string to display.
2. split it into each character
3. for each character, find where it is on the texture (one big texture with the character table on it)
4. display a quad with texcoords so that only the character is on it
5. move to the right so the next quad is beside it.
You can do fancy effects using blending to make them less obviously quads. Pick the right blending function and you will see through them.
urika
09-04-2003, 03:05 AM
sounds like a pretty good idea, i hope i succeed.
how can i move the quads to always be 90 degrees to the camera?
is there like a reverse "glLookAt"?
starboarder2001
09-04-2003, 11:18 AM
I use the wiggle function "wglUseFontBitmaps(...)" to generate the bitmaps
Then do something like this..
//Clear Buffers
//Load Identity
//Set Camera (gluLookAt)
//Render Scene
//Load Identity -clear indentity matrix
//Render text
baldurk
09-04-2003, 12:05 PM
how can i move the quads to always be 90 degrees to the camera?
Google for "billboarding" techniques.
I use the wiggle function "wglUseFontBitmaps(...)" to generate the bitmaps
Although that's possible, I'd say it's a much better idea to create your own texture and load it. It doesn't require the font to be on the persons computer, and it's more cross-platform :). (actually, wgl isn't cross-platform at all).
davepermen
09-05-2003, 09:41 AM
NeHe (http://nehe.gamedev.net) has some nice font/text tutorials. for all sort of needs.
urika
09-07-2003, 02:08 AM
baldurk, u mean to put quads with texture (text) on them?
baldurk
09-07-2003, 02:55 AM
yes. You have a string of quads, each with one character on the front.
You might find it useful to download my demo, as it uses this method of displaying text. Please don't copy-paste the code though.
urika
09-07-2003, 09:09 AM
soory but how do i find your demo?
baldurk
09-07-2003, 09:45 AM
Here (http://www.glprogramming.com/baldurk/khaos.zip) is a direct link. It was for this (http://www.devmaster.net/forums/index.php?t=73) contest.
urika
09-07-2003, 10:36 AM
looks real cool (and sounds)
was the credits text done in the same way? (thats like what i need)
baldurk
09-07-2003, 11:34 AM
thank you :).
Yes, all the text was done in the same way.
vBulletin, Copyright ©2000-2009, Jelsoft Enterprises Ltd.