I am working with the OpenGL ES 2.0 Platform on Android and I am having difficulty using the destination alpha blending functions because I dont think I am requesting an alpha buffer when I create the GL context.
I am trying to use a black and white texture to mask a foreground texture so that certain parts of the foreground texture do not appear and the background texture is blended into the foreground texture.
The Method I am using is as follows:
glEnable(GL_BLEND);
// Use a simple blendfunc for drawing the background
glBlendFunc(GL_ONE, GL_ZERO);
// Draw entire background without masking
drawQuad(backgroundTexture);
// Next, we want a blendfunc that doesn't change the color of any pixels,
// but rather replaces the framebuffer alpha values with values based
// on the whiteness of the mask. In other words, if a pixel is white in the mask,
// then the corresponding framebuffer pixel's alpha will be set to 1.
glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO);
// Now "draw" the mask (again, this doesn't produce a visible result, it just
// changes the alpha values in the framebuffer)
drawQuad(maskTexture);
// Finally, we want a blendfunc that makes the foreground visible only in
// areas with high alpha.
glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
drawQuad(foregroundTexture);
But it seems the blendfunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA); does not work because I cannot blend the destination alpha with android without requesting an alpha buffer when I make the context.