• 15
• 15
• 11
• 9
• 10

Alpha blending problems!

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

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 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 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 on other sites
post your draw loop in [ source][/source] tags.

-me

Share on other sites
// part of my image draw functionglEnable(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 functionglBlendFunc(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 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 on other sites
you've not done something daft like forgotten to enable blending have you?

No I did.

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