View Full Version : glFont / glBlendFunc help needed

08-26-2009, 02:45 PM
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.


08-27-2009, 05:18 AM
Try to glDisable( GL_DEPTH_TEST ); when drawing your ingame interface. Don't forget to enable it back afterwards.

08-28-2009, 10:16 AM
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.

08-28-2009, 02:24 PM
haha works perfectly now, thanks alot :)

08-28-2009, 02:37 PM
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.

11-22-2009, 04:31 AM
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.

12-06-2009, 08:33 AM
hmm an alpha textured font could work.