PDA

View Full Version : glFont / glBlendFunc help needed



Simo00
08-26-2009, 03: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.

Thanks

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

ColacX
08-28-2009, 11:16 AM
I have the exact same problem from using the code from
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17

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

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

Simo00
08-28-2009, 03: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:

glClearColor(0.0,0.0,0.0,1.0);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);

Draw my in-game interfaces,

Draw my in-game text using the glFont method.

Hope this helps.

ColacX
11-22-2009, 05: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.

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