Archived

This topic is now archived and is closed to further replies.

SoD

Font and blending

Recommended Posts

SoD    122
How it''s possible to render text with a font texture (like last nehe font lessons) without using blending? the blend factor remove the black parts around each char in the texture but makes them trasparent, i can see the things "behind" the text. I''ve to use masking? How? i need a mask texture of the font texture? or i can do it using only code?

Share this post


Link to post
Share on other sites
vincoof    514
Try NeHe''s code with this initialization :
glAlphaFunc(GL_EQUAL, 1.0f);
glEnable(GL_ALPHA_TEST);

It will have no black border, it will have no blended part, but OpenGL''s blending still allow you to see through "empty" parts of the texture.
But the problem is that your texture isn''t smoothed anymore.

Share this post


Link to post
Share on other sites
Do00d    122
use a file format with a alpha channel such as .tga
thatll solve that problem and others that u WILL get due to other textures which ull find out if u keep going
i did and dropped my bmps

Share this post


Link to post
Share on other sites
vincoof    514
Do00d: that will result in black borders, IMO.

SoD: there is also another solution, which is a bit more elegant than the one I described.
When you load the texture, don''t load it as a RGBA texture, but just load tha alpha channel. It will eliminate the black borders.
This means that'' you''ll have to colorize the text yourself (obviously with commands like glColor).
To have an antialiased border, then do this :
glDisable(GL_BLEND);
glAlphaFunc(GL_GREATER, 0.5f);
glEnable(GL_ALPHA_TEST);
/* draw your text here */
glDisable(GL_ALPHA_TEST);
glEnable(GL_BLEND); // if you need blending, enable it again

Share this post


Link to post
Share on other sites