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

## 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 on other sites
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 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 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 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 on other sites
I guess then I would be wrong. I learned something today ;).

##### Share on other sites
i would recommend SDL_ttf for font rendering.

##### Share on other sites
Has anyone used the glut font rendering? If so can you tell me how good it is, if you had any problems with it etc.

##### Share on other sites
what's with freetype?

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002034
×