Reputation: 292
I'm trying to achieve a fade effect, where the corners of a square have different alphas. I'm doing this:
glBegin(GL_QUADS);
glColor4d(r, g, b, alphaTopLeft);
glVertex2d(x, y);
glColor4d(r, g, b, alphaTopRight);
glVertex2d(x + width, y);
glColor4d(r, g, b, alphaBottomRight);
glVertex2d(x + width, y + height);
glColor4d(r, g, b, alphaBottomLeft);
glVertex2d(x, y + height);
glEnd();
With the values alphaTopLeft = 0, alphaTopRight = 0, alphaBottomRight = 1, alphaBottomLeft = 1, but it produces a solid shape (all corners alpha 1), why?
Upvotes: 1
Views: 65
Reputation: 1486
Have you enabled GL_BLEND
? Try adding this before you render:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable( GL_BLEND );
Upvotes: 3