PDA

View Full Version : Text blending



NeoTuri
04-12-2001, 06:58 AM
I wanted to know if there was a different and maybe better way to do this:

I'm currenting using a font from a single texture (font=white,bg=black). When I want to draw it onto objects with blending, let's say, [font=white,bg=blue]:

glDisable( GL_BLEND );
draw_text();
glEnable( GL_BLEND );
glBlendFunc( GL_ONE, GL_ONE );
drawObject();

I usually have to predict the blend result when calling glBlendFunc(). Say I want to do this:
[font=black,bg=red]

glDisable( GL_BLEND );
glColor2f( 1, 0, 0 );
drawObject();
glEnable( GL_BLEND );
glBlendFunc( GL_ZERO, GL_ONE_MINUS_SRC_COLOR );
glColor3f( 1, 1, 1 );
glColorMask( GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE );
draw_text();

Is there a better way to do this?