Jump to content


tutorials on text


11 replies to this topic

#1 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 03 September 2003 - 02:29 PM

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:

#2 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 03 September 2003 - 05:16 PM

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.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

#3 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 04 September 2003 - 09: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"?

#4 starboarder2001

    Member

  • Members
  • PipPip
  • 35 posts

Posted 04 September 2003 - 05:18 PM

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
1000
0100
0010
0001

#5 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 04 September 2003 - 06:05 PM

Quote

how can i move the quads to always be 90 degrees to the camera?

Google for "billboarding" techniques.

Quote

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).
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

#6 davepermen

    Senior Member

  • Members
  • PipPipPipPip
  • 1306 posts

Posted 05 September 2003 - 03:41 PM

NeHe has some nice font/text tutorials. for all sort of needs.
davepermen.net
-Loving a Person is having the wish to see this Person happy, no matter what that means to yourself.
-No matter what it means to myself....

#7 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 07 September 2003 - 08:08 AM

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

#8 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 07 September 2003 - 08: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.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

#9 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 07 September 2003 - 03:09 PM

soory but how do i find your demo?

#10 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 07 September 2003 - 03:45 PM

Here is a direct link. It was for this contest.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.

#11 urika

    Member

  • Members
  • PipPip
  • 54 posts

Posted 07 September 2003 - 04:36 PM

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

#12 baldurk

    Senior Member

  • Members
  • PipPipPipPip
  • 1057 posts

Posted 07 September 2003 - 05:34 PM

thank you :).

Yes, all the text was done in the same way.
baldurk
He who knows not and knows that he knows not is ignorant. Teach him.
He who knows not and knows not that he knows not is a fool. Shun him.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users