Jump to content

  • Log In with Google      Sign In   
  • Create Account

Alpha blending oddity


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 seregsarn   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 January 2002 - 03:04 PM

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); }

Sponsor:

#2 Cirian   Members   -  Reputation: 122

Like
Likes
Like

Posted 07 January 2002 - 09:18 PM

GL_DEPTH_TEST fux0rs up alpha blending.... make sure it is off.
Also, check your glBlendFunc(...)

#3 seregsarn   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 January 2002 - 07:48 AM

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

#4 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 08 January 2002 - 08:02 AM

do u have alpha testing enabled and if so is it set to 0.5

http://uk.geocities.com/sloppyturds/gotterdammerung.html

#5 seregsarn   Members   -  Reputation: 122

Like
Likes
Like

Posted 08 January 2002 - 08:14 AM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS