I want to do normal blending with OpenGL, like the blending between layers in Photoshop for example, but it doesn't seem possible with glBlendFunc.

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) does not work as expected because if I start with a transparent buffer, render a solid primitive and then render a semi-transparent, the result is semi-transparent even if I did render something totally solid in between.

That's just all wrong, and it does not work for me.

How can I do normal blending where the alpha value is calculated as 1 - (1-As)*(1-Ad) ?