I'm trying to mask a texture on top of a background texture. I have the following 3 images being used as background (dark green), mask and foreground(checkered light green) respectively.
This is what I have in my code:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
bg.draw(0, 50);
glBlendFuncSeparate(GL_ZERO, GL_ONE, GL_SRC_COLOR, GL_ZERO);
mask.draw(0, 50);
glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
fg.draw(0, 50);
I'm following the answer in this post: OpenGL - mask with multiple textures
Now, what I expected is when I draw the foreground, only the portion of the mask which is white would be displayed with the foreground colour, but I'm seeing the entire foreground displayed. The answer in the post I mentioned above says that I need to request for destination alpha while setting up the EGL context. So I tried this as well:
getHolder().setFormat(PixelFormat.RGBA_8888);
setEGLContextClientVersion(2);
renderer = new GLRenderer();
But this didn't make any difference either. I still see the entire foreground. I wanted to know how to enable destination alpha. Also any alternatives to achieve the desired result would be welcome.