glFont / glBlendFunc help needed

Hi, just got a problem with glFont.

In my game i use glFont to display my text, but i originally had a problem that surrounding each letter was a black box. I used glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) to solve this.

However this only works properly when i want to display my text in front of a 3D object. If i display the text in-front of my in-game interfaces (drawn in 2D ortho mode) the black boxes are removed, however so are sections of the interface where the black boxes would have been.

i.e. it produces ‘holes’ in the interface and lets you see the through to the rest of the game world, where ideally i want my interface with the text on top.


Try to glDisable( GL_DEPTH_TEST ); when drawing your ingame interface. Don’t forget to enable it back afterwards.

I have the exact same problem from using the code from

I guess there’s no other solution than to calculate which one that is closer to the viewer the object or the text.

haha works perfectly now, thanks alot :slight_smile:

Hi ColacX, the method that i’ve used is as follows:

My basic game loop is:

Draw my 3d game world in projection mode,
Change to 2d - orthographic mode,
then set:


Draw my in-game interfaces,

Draw my in-game text using the glFont method.

Hope this helps.

What did you do with with your ingame 3D text?

I dont have a 2D interface in mine i just want the 3D text to display properly.

with depthtest enabled the text flickers
with depthtest disabled the text gets drawn infront of other objects. i see no way to solve this unless i calculate which object is closest to me.

hmm an alpha textured font could work.