Sign in to follow this

Better alternative for font in C++ OpenGL

Recommended Posts

Hi there,

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

this is the result in my game:


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

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.


Share this post

Link to post
Share on other sites
You probably want to use [url=""]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=""]BMFont[/url] is a tool that can be used to construct font texture atlases. Our very own Promit once wrote an [url=""]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