If you want to achieve a blending of textures with transparency (like PNG) that is similar to UIKit, how do you configure OpenGL ES 1.1 appropriately?
I found:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_ALPHA_TEST);
But there is also:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
You should use
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
. The other one has no respect for the alpha channel at all in this case, it will simply sum up the source and destination colours for you.There is one thing you should note though. This will work great on colours but your destination alpha channel will not be correct. In most cases you do not use it but if you wish to extract the image from buffer with the alpha channel as well you will need it, same goes for using FBO and reuse texture with transparency. In this case you should draw the alpha channel separately using
glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE)
. This means doubling the draw calls (at least I can't think of a better solution without shaders). To draw to colour only you have to setglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE)
and to draw alpha only useglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE)
To sum up: