Jump to content
  • Advertisement
Sign in to follow this  
Tera_Dragon

OpenGL 2D font library

This topic is 4796 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

I want to use 2D font, like the windows bitmap font, but with which I can specify the character width and height (fixed width and height fonts) in pixels, or somehow get this information. I have tried glfont, but this is not what I am looking for as it uses the opengl coordinate system and not pixels. Thanks in advance for any help.

Share this post


Link to post
Share on other sites
Advertisement
I've just found this incase anyone else has had the same problem. Though if you know of something that isn't on that list and is good, please do tell ;)

Share this post


Link to post
Share on other sites
You can always write wrapper so that those units are transformed to pixels... or use such OGL coordinate system where each unit == pixel...



void SC :: Renderer :: Enter2DMode()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

/*
Inits orthographical projection. In this mode, screen looks like this:
(0,0) is left down corner of screen
(screenWidth-1, screenHeight-1) is upper right corner of screen
*/

glOrtho (0, screenWidth, 0, screenHeight, 0, -100); // it must be called for MODELVIEW

glMatrixMode( GL_PROJECTION );
glLoadIdentity();

}





Or use SDL_TTF (like here: clicky).

Share this post


Link to post
Share on other sites
edit: me slow, Koshmaar beat me to it (actually I'm fairly certain you need to call xxOrtho() in GL_PROJECTION mode but I may be wrong).

You can make the OpenGL coordinate system correspond to pixels by switching to ortho mode with the appropriate settings:


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT);
// make sure to set back to modelview before drawing stuff



Share this post


Link to post
Share on other sites
Heh, you were only half a minute slower... :-)

Anyway, I've tried calling glOrtho for projection matrix and it didn't work. So, I've tried calling it for modelview, and it works... yes, for me it's illogical too. But I can't argue with what I see on screen :-/

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!