Jump to content
  • Advertisement
Sign in to follow this  
DarkNebula

Alpha blending problems!

This topic is 5080 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Below is a picture of my main menu, and the buttons have a black background and I changed the black to alpha, but it doesn't seem to work correctly. What could be wrong? I'm using: glBlendFunc(GL_ALPHA, GL_ONE); Or is there a tutorial that I can find that will help me do this correctly? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
are you drawing the background first? you need to draw alpha'd things last and in back to front order. you also seem to have aplha blending working fine on the game title and on the user_name/password images/quads so what's different between those images and the buttons?

-me

Share this post


Link to post
Share on other sites
The title image is part of the picutre so is the user name and password text. I draw the background first, then I draw the buttons, so they are on top.

Share this post


Link to post
Share on other sites


// part of my image draw function
glEnable(GL_TEXTURE_2D);
glLoadIdentity();
glTranslatef(x, y, 0.0);
glColor3fv(glWhite);
glBlendFunc(GL_ALPHA, GL_ONE);
glBindTexture(GL_TEXTURE_2D, texture->TextureID);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, height);
glTexCoord2f(1.0, 1.0); glVertex2f(width, height);
glTexCoord2f(1.0, 0.0); glVertex2f(width, 0.0);
glEnd();
glDisable(GL_TEXTURE_2D);

// part of my button draw function
glBlendFunc(GL_ALPHA, GL_ONE);
glTranslatef(x, y, 0.0);
glColor3fv(glWhite);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0);
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, height);
glTexCoord2f(1.0, 1.0); glVertex2f(width, height);
glTexCoord2f(1.0, 0.0); glVertex2f(width, 0.0);
glEnd();

Share this post


Link to post
Share on other sites
It seems its not an alpha blend problem but a problem all together. The image even without blending looks like that. What can be wrong with it?

Share this post


Link to post
Share on other sites
Can you post the button image (as a BMP)?

try using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

GL_ALPHA is not a valid blend mode..

Share this post


Link to post
Share on other sites
Well, there are a few things you're not telling.
* You "changed the black to alpha" - does this mean you just set the alpha of the black areas to zero, and the rest to one? If the problem is that the outline of the buttons isn't smooth, you should just smooth the outline in a paint program so that the alpha doesn't go directly from one to zero.
* What is the effect you're trying to achieve? Is the background supposed to be visible through the buttons? If not, you should render the buttons with glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA).
* Maybe you could post your button texture? I'd like to know what it looks like before it's applied - it'd give me a better idea of what the end result should look like :)

EDIT: Ilici probably found the problem - it's supposed to be GL_SRC_ALPHA, not GL_ALPHA

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!