PDA

View Full Version : blending with fonts



Alien999999999
06-07-2004, 07:28 AM
I have a environment that's drawn, i want a 50% rect partially above it and then i want text drawn above it, the thing is that i seem not to be able to get my color anymore, what glBlendFunc options should be passed and do i put the glColor before or after that call?

/* draw polygons */
...
/* draw translucent polygon */
glColor4b(127,127,127,50);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(4,15,1);
glVertex3f(4,477,1);
glVertex3f(635,15,1);
glVertex3f(635,477,1);
glEnd();
/* drawing text */
glBlendFunc(GL_ONE,GL_ZERO);
glDisable(GL_BLEND);
glColor4b(-100, 127, -108, 127); /* make everything appear in Green */
...

since i enabled blending, the font appears in black instead of the green color i selected

06-07-2004, 04:55 PM
if you want to alpha blend the text you need to keep blending enabled. but this wouldn't make your text black - post the text drawing code.

Alien999999999
06-09-2004, 04:56 AM
the text itself does not need alpha blending, i have fixed it, it appeared that if lighting was enabled when drawing the text, that it appeared black.

the current code is now this:

if(!gGLX->pausetext)
{
/* try drawing a square with transparent background */
glEnable(GL_LIGHTING);
glColor4b(127,127,127,63);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(4,15,1);
glVertex3f(4,477,1);
glVertex3f(635,15,1);
glVertex3f(635,477,1);
glEnd();
glBlendFunc(GL_ONE,GL_ZERO);
glDisable(GL_BLEND);
glDisable(GL_LIGHTING);
}
/* drawing hud_text */
glColor4b(-100, 127, -108, -128); /* make everything appear in Green */