Alpha blending oddity
I''m trying to use a simple quad to draw a flat (24-bit plus 8-bit alpha layer) TGA image overlayed on the viewport (a HUD image, incidentally). Everything seems to be working fine, but when I tried to add alpha blending, I discovered an oddity of sorts. Alpha values greater than 128 work perfectly fine, as far as I can tell. But for whatever reason, anything below is truncated to 0, almost as if it were screwing with the high bit of the alpha layer.
Code snippet follows:
if (hud->has_alpha) {
glEnable(GL_BLEND);
glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
glBindTexture (GL_TEXTURE_2D, hud->texnum)
glBegin (GL_QUADS);
glTexCoord2f (0, 0);
glVertex2f (x, y);
glTexCoord2f (1, 0);
glVertex2f (x+hud->width, y);
glTexCoord2f (1, 1);
glVertex2f (x+hud->width, y+hud->height);
glTexCoord2f (0, 1);
glVertex2f (x, y+hud->height);
glEnd ();
if (hud->has_alpha) {
glDisable(GL_BLEND);
glTexEnv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
GL_DEPTH_TEST fux0rs up alpha blending.... make sure it is off.
Also, check your glBlendFunc(...)
Also, check your glBlendFunc(...)
Hm. Turning off GL_DEPTH_TEST beforehand is probably a good idea, but it didn''t solve the problem. I also explicitly set the blend function to GL_SRC_ALPHA/GL_ONE_MINUS_SRC_ALPHA. Still no change, as far as I can tell. I think there might be a problem somewhere else in the code that''s messing with the texture itself, but I can''t find it anywhere.
I may be forced to just list it as a feature. ;P
I may be forced to just list it as a feature. ;P
do u have alpha testing enabled and if so is it set to 0.5
http://uk.geocities.com/sloppyturds/gotterdammerung.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement