I am rendering anti-aliased lines onto a transparent background - the idea being to save as a PNG with alpha channel, and the overlay against different backgrounds.
I’m having problems getting the blending to work well. I’m using
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
This works well, so long as the lines are the same colour as the pre-cleared background. For example, I use
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
This gives a nice base for drawing black lines. But, if I draw white lines, the white doesn’t come through. Ideally, the first time a pixel is drawn, it should completely overwrite the colour planes, and add it’s alpha into the alpha channel. Then subequent writes should do the blending. But, there doesn’t seem to be a way to do this.
I’m using depth buffering with non-sorted lines. There are also some polygons in my render, and drawing transparent polyons also has the same issue.
Any ideas? It seems a simple test to check the dest alpha, but OpenGL doesn’t seem to have the necessary options to work correctly with dest alpha!
I’d love a solution for this.