Sign in to follow this  

Alpha blending problems!

This topic is 4868 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
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


// 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
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

This topic is 4868 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this