OpenGL fonts, what is the best way to go?

Started by
28 comments, last by Roots 19 years, 3 months ago
I've already read some tutorials about font rendering using OpenGL, and implemented 2D Bitmap Fonts (NeHe lesson 17). Now, I'm starting a new project, and want to know if this is really the best way to follow. I know a interesting alternative: - GNU Freetype library: seems very good to me, but from what I've read from NeHe it has a somewhat bigger overhead than other methods; What do you think is the best way out? What do you currently use in your projects to output text? I'm safe with FreeType? Thanks!!! PS.: the project I'm working on must be multiplatform, thus I can't use "wgl" or other OS dependent stuff.
Advertisement
For most practical purposes, you can simply make an image of the words you need and manipulate them. If I need anything larger, I usually use bitmap fonts, although I use vector arrays rather then display lists like nehe does.
glFont works great.

http://students.cs.byu.edu/~bfish/glfont.php

Quote:Original post by Binomine
For most practical purposes, you can simply make an image of the words you need and manipulate them. If I need anything larger, I usually use bitmap fonts, although I use vector arrays rather then display lists like nehe does.

As I will also use text output for debugging purposes and character "speech", image words seems not to be the best way to go.

Thanks, Binomine!!!
Quote:Original post by Vampyre_Dark
glFont works great.
http://students.cs.byu.edu/~bfish/glfont.php


Very interesting, Vampyre, but I can't rely on a specific operating system, and this solution seems to be not so flexible.

Thanks anyway!!!
texture fonts was the only cross platform font i could find. but its also really flexible, you can make it any color and scale and rotate it just like any other quad. check out this NeHe tutorial.

if you dont want to do that, google for "GLFT", i heard it is a good library for fonts.
FTA, my 2D futuristic action MMORPG
I use SDL_TTF, this implies you're using SDL, and if you're going multi platform I highly recommend it. It looks nice (AA) and supports Unicode(you can write in japanese), and it's easier to change fonts (and font size).

The problem is getting it to work (handling character returns, tabs, and getting the data to a texture) and work fast. For instance generating a new texture every frame for a fps counter will kill the fps, so you need to update the texture (or better just a subsection of it). It took me a while to get it to a nominally cost.

Bitmap fonts tend to be good enough for most peoples needs though, and they're pretty easy to get working well.
Since I could never get SDL_TTF to work with OpenGL (More specifically I couldn't work out how to convert an SDL_Surface* to an OpenGL texture) I use BMF_Font http://trenki.50free.org/bmf/
But if something better comes along Im happy to use it.
I heard that the Freetype library is pretty hard to use.
Quote:Original post by sand_man
Since I could never get SDL_TTF to work with OpenGL (More specifically I couldn't work out how to convert an SDL_Surface* to an OpenGL texture) I use BMF_Font http://trenki.50free.org/bmf/
But if something better comes along Im happy to use it.
I heard that the Freetype library is pretty hard to use.


Very interesting, Sand_man! And, to convert as SDL_Surface to an OpenGL texture:

void C_Texture::createTexture( GLuint *texture, char *textureName ) {    // SDL_Surface *textureImage;    if ( textureImage = SDL_LoadBMP( textureName ) ) {        glGenTextures( 1, texture );        glBindTexture( GL_TEXTURE_2D, *texture );	glTexImage2D( GL_TEXTURE_2D, 0, 3, textureImage->w, textureImage->h, 0, GL_BGR, GL_UNSIGNED_BYTE, textureImage->pixels );	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );	glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );    }}
Quote:Original post by Cocalus
I use SDL_TTF, this implies you're using SDL, and if you're going multi platform I highly recommend it. It looks nice (AA) and supports Unicode(you can write in japanese), and it's easier to change fonts (and font size).

Very interesting!

Quote:
The problem is getting it to work (handling character returns, tabs, and getting the data to a texture) and work fast. For instance generating a new texture every frame for a fps counter will kill the fps, so you need to update the texture (or better just a subsection of it). It took me a while to get it to a nominally cost.

Ah, using glTexSubImage2D...


Bitmap fonts tend to be good enough for most peoples needs though, and they're pretty easy to get working well.
Yes, they are fine.

This topic is closed to new replies.

Advertisement