Jump to content
  • Advertisement
Sign in to follow this  
John_23

glRasterPos2f- hopefully an easy question

This topic is 4240 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 all. This should be an easy question? glRasterPos2f(0.0f, 0.0f); glPrint("Hi Everyone"); Now at the moment the text starts being printed at 0.0f, whereas I want the text centered. Anyone know how to do that? Sorry to ask that question, for some reason never used bit-mapped fonts before :~/ Thanks [smile], John

Share this post


Link to post
Share on other sites
Advertisement
the easy answer is magic number it over to where it is centered. the hard and robust answer: OpenGL does not support this and you have to make GDI calls (under Windows) to calculate your texts rectangle, then map that rectangle to your 2d projection coordinates in OpenGL.

the GDI function is DrawText, with a DT_CALC_RECT passed in IIRC
and the OpenGL function i typically use is gluOrtho2D (with the window size in pixels to map to pixelspace).

Share this post


Link to post
Share on other sites
I was pondering over it today and an answer hit me and I felt a bit stupid afterwards. Just position the text at 0 - ((length of string) / 2). That should do it I think :)

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!