tutorials on text

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 03, 2003 at 14:29

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:

11 Replies

Please log in or register to post a reply.

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Sep 03, 2003 at 17:16

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.

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 04, 2003 at 09:05

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”?

F699ebb187331fdf7f7875320e3e7e3e
0
starboarder2001 101 Sep 04, 2003 at 17:18

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

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Sep 04, 2003 at 18:05

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).

6ad5f8c742f1e8ec61000e2b0900fc76
0
davepermen 101 Sep 05, 2003 at 15:41

NeHe has some nice font/text tutorials. for all sort of needs.

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 07, 2003 at 08:08

baldurk, u mean to put quads with texture (text) on them?

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Sep 07, 2003 at 08:55

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.

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 07, 2003 at 15:09

soory but how do i find your demo?

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Sep 07, 2003 at 15:45

Here is a direct link. It was for this contest.

F923e021a633170fb10416df23dffddd
0
urika 101 Sep 07, 2003 at 16:36

looks real cool (and sounds)
was the credits text done in the same way? (thats like what i need)

0684f9d33f52fa189aad7ac9e8c87510
0
baldurk 101 Sep 07, 2003 at 17:34

thank you :).

Yes, all the text was done in the same way.