I have to draw texture with transparent areas on square. But I don't want this transparencies to take color from this polygon, but from the background. Do you have any good tutorial to achieve it?




  glTexCoord2f(0,0); glVertex3f(-0.5, -0.5, -1);
         glTexCoord2f(1,0); glVertex3f(1, -1, -1);
         glTexCoord2f(1,1); glVertex3f(0.5, 0.5, -1);
         glTexCoord2f(0,1); glVertex3f(-0.5, 0.5, -1);


I just takes color from polygon. How to make this polygon transparent.


OpenGL provides blending function.

glEnable(GL_BLEND);// you enable blending function
// then you will set flags to achieve desired blending effect.

For further different usage, read http://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

However for your particular case, the desired effect, applying transparency, I believe you want...

"...Examples Transparency is best implemented using blend function (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) with primitives sorted from farthest to nearest. Note that this transparency calculation does not require the presence of alpha bitplanes in the frame buffer."


Not the answer you're looking for? Browse other questions tagged or ask your own question.