I am trying to mask an image with OpenGL so that part of it is transparent. Here's my code, which isn't working:
draw_img(background);
...
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glBlendFunc(GL_ONE, GL_ZERO);
draw_img(mask);
glBlendFunc(GL_DST_ALPHA, GL_ONE_MINUS_DST_ALPHA);
draw_img(foreground);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Here is my background image, over which I am trying to draw:
Here are the texture and the mask, respectively (The white in the mask is really transparent, I just flattened it so you can see):
This is what I expect to get:
And this is what I actually get:
Any idea what might be the problem?