Jump to content
  • Advertisement
Sign in to follow this  
e_pech

OpenGL Text in OpenGL

This topic is 3751 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey! Does anyone know how I can output text in OpenGL but in a way I'll be able to manipulate the vertices (know the exact size of the whole text drawn, slant it at any inclination, and some other things)... I'm using C++ w/MFC and the WglUseFontOutlines function, however I can't manipulate the vertices and for me it's kind of limited so, I was wondering if anyone has an idea of any other way I can output text. By the way, I'd like to use LINES and not Rasters or Bitmaps. Thank you sooo much and if I'm being really picky, it's not me, it's my boss hehehe :D

Share this post


Link to post
Share on other sites
Advertisement
Lord Evil, you're the man... I'm learning all this OpenGL stuff... I'm a newbie... so I was trying to solve the problem using a wrong technique! Matrices DO the job (for Shearing)! I had to read a little bit about it (almost an hour) but I solved the problem! Thanks man!!

Do you by a chance know how I can find out the exact size of a text drawn on the screen??

Thanks a lot!

Share this post


Link to post
Share on other sites
I think you should use the last parameter of wglUseFontOutlines: LPGLYPHMETRICSFLOAT (a pointer to a GLYPHMETRICSFLOAT array).

This should contain the default sizes for each character (glyph). With that and your projection matrix, viewport and scaling settings you should get the rendered size.

Here's the corresponding MSDN article.

Share this post


Link to post
Share on other sites
Yeah, I'm trying to use those attributes of that structure however, I don't know what I'm doing wrong because no matter what Letter I output it always gives me the same size... BlackBoxX, BlackBoxY, gmfCellIncX, etc... the parameter doesn't change...

I want to center text on the screen so... I Substract the size of one Letter (let's suppose I'm just drawing a letter, nothing else on the screen, my Ortho2D is set to 0 - 10) so... I just do (10 - textSize)/2. Right?

But, the thing is that if I want to output 15 letters or so... every single letter has a different size and apparently(width of 'i' is less than 'M'), PLEASE correct me if I'm wrong those attributes won't change, I even tried

agmf[0]->Attribute

and I tried it changing the array index and still the same thing....

I hope I was clear!

I appreciate your help!

Share this post


Link to post
Share on other sites
Might depend on your font, since there are monospaced fonts out there,i.e. size of "i" = size of "m".

Also, for centering the text you need to be aware where the origin of the text is. I personally use texture mapped fonts with freetype which uses the leftmost bottomline coordinate as the origin (compare "f" and "q" for the bottom line -> q expands below the line).

So vertical centering should be: y = (screenHeight - textHeight)/2 + distanceTopToOrigin.

Share this post


Link to post
Share on other sites
Thnx man! I'll take a look at it! I appreciate your follow up and help... For now, I'll go and hit the sack for a little bit.. Here in Mexico it's 4.30am....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!