Alpha blending oddity

Started by
3 comments, last by seregsarn 22 years, 3 months ago
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); }
-----------------"I understand your concern. Request denied."
Advertisement
GL_DEPTH_TEST fux0rs up alpha blending.... make sure it is off.
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 understand your concern. Request denied."
do u have alpha testing enabled and if so is it set to 0.5

http://uk.geocities.com/sloppyturds/gotterdammerung.html
Ah! That was the problem, I wasn''t forcing the appropriate alpha function. Setting it to (GL_NOTEQUAL, 0) turned out to work.

Thanks for all your help, both of you.
-----------------"I understand your concern. Request denied."

This topic is closed to new replies.

Advertisement