Jump to content
  • Advertisement
Sign in to follow this  
MajinMusashi

OpenGL OpenGL fonts, what is the best way to go?

This topic is 5049 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'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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!!!

Share this post


Link to post
Share on other sites
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!!!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 );
}
}


Share this post


Link to post
Share on other sites
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...

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

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!