Sign in to follow this  
raphaelvanier@videotron.ca

Better alternative for font in C++ OpenGL

Recommended Posts

Hi there,

I am currently using the font trick from nehe tutorial in my game:

http://nehe.gamedev.net/tutorial/bitmap_fonts/17002/ (the tutorial)

this is the result in my game:

[img]http://www.imagitiel.com/forum/writing1.jpg[/img]

First of all, I am applying an alpha of 0.1 to the image and text with the following code:

glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glColor4f (1,1,1, alpha);

font->glPrint(text.c_str()); // Print GL Text To The Screen
// render the image the same way.

glColor4f (1,1,1, 1.0f);

2 problem:
- The alpha blending work with the image but not with the text.
- The text is choppy and pixelized. I am using "Calibri" height 28, bold.

So... My question is, is the a better alternative to writing 2D text on the screen without these 2 problems? Other than putting my font in an image and cutting it out in tiles of course.

Thanks.

Share this post


Link to post
Share on other sites
You probably want to use [url="http://freetype.org"]Freetype[/url] to render your text to a texture and then just display that. Look into Texture Atlases and Knapsack heuristics if you want to really go in-depth.

Share this post


Link to post
Share on other sites
[url="http://www.angelcode.com/products/bmfont/"]BMFont[/url] is a tool that can be used to construct font texture atlases. Our very own Promit once wrote an [url="http://www.gamedev.net/topic/330742-quick-tutorial-variable-width-bitmap-fonts/"]article[/url] about loading and using them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this