Opengl Text

Started by
7 comments, last by Stani R 16 years ago
What are you guys currently using? I'm using bitmap fonts, and i'm curious if i should be using something better.
Black Sky A Star Control 2/Elite like game
Advertisement
Textured polygons. The textures are generated at startup.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
But this technique requires more power from GP.
Quote:Original post by Mortilles
But this technique requires more power from GP.


What technique?
Textures are stored in VRAM and vertices are in a VBO (also in VRAM), so there is as little delay as possible when rendering.

wglUseFontBitmaps is a black box. No one knows what it does exactly but it's a 15 year old code written by MS.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Yeah I finally wrote a damn center function that i needed desperately.

Texture mapped fonts seem like the best option, but it would be nice to have variable width characters.

I know promit wrote some code for one a while back.

Only problem I have with bitmap fonts is they are windows only and no AA on the fonts...
Black Sky A Star Control 2/Elite like game
use textured polygons and freetype, it's fast, free and you can use ANY TTF font. See nehe's for a tutorial that does the whole thing. Oh variable width is no problem with freetype based fonts :)
I texture my text and translate each character according to a predefined width in an array. I like being able to draw my own fonts. :)
Using D3D (Although the concept should map to OpenGL easily):
I use a Win32 DIB section and draw characters into that, then copy the bit data to a texture. GetGlyphOutline then tells you the size and shape of the letter, which I cache and use to spit out vertices.
I use a bitmap font. Texture is 16x16 evenly spaced characters, texturing quads with them and compiling as a sequence of display lists. I think I based this on Nehe or on some LWJGL tutorial, can't really remember. I mean to replace it with AngelCode fonts eventually but so far that feature has been low-priority.

This topic is closed to new replies.

Advertisement