Original Post
Hello all. I'm having a problem with OpenGL that has me stumped. I'm trying to render a font with alpha transparency but it just isn't working. I'm using a png file with an alpha channel for my textured font. I'm also using SDL to hold the texture data. I then generate my texture using gluBuild2DMipMaps. Here is the code I use to generate a texture with SDL and OpenGL.
As you can see, the printf's show what type of data i'm using. Here's the output for my font.png character map.
|
Getting ready to load image
1) Building mipmap with GL_RGBA
2) Image has alpha transparency
I'm using GL_RGBA for the color mode and it's telling me the surface has alpha transparency. ok. So before I render my 2d font, I've tried calling the following function
void alpha()
{
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, .242);
}
this function doesn't affect the transparency at all. I still have big blocks around my letters. I've also tried this function
void blend()
{
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glDepthFunc(GL_LEQUAL); // Type Of Depth Testing
glEnable(GL_DEPTH_TEST); // Enable Depth Testing
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Enable Alpha Blending (disable alpha testing)
glEnable(GL_BLEND);
}
but alas, this does not work either. I would really like some help on how to render my font with alpha transparency. Thanks.