Reputation:
I draw an image as a back on the screen first, then draw a mask for a picture like this: it is a circle with a white color in the middle, and all of the left is black. I use glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); to make it display only the white circle on the back image. Then I need to draw another image on the same position of mask. My aim is to make this image only be drawn where the part is corresponding with the white circle. In fact what I want to draw is a moon. And I must make it opaque. What should i do?
Upvotes: 0
Views: 216
Reputation: 25680
Just put the black/white in the alpha channel of the moon image? That is probably the most sensible thing you can do, and it follows convention.
Or, if you're committed to your approach. render your black/white into the alpha part of the frame buffer (it's probably there already if you do what you say you do) then use DST_ALPHA instead of SRC_ALPHA for the next pass. However, this is not how one usually does it in OpenGL.
Upvotes: 1
Reputation: 3024
I don't know if I am just not understanding correctly the question, but couldn't you use just a single image, with the circle and the last used image in it?
If that don't fits, you could use the stencil buffer: Setting it to a value when drawing the second image and rendering only on those pixels at that value in the third image.
Upvotes: 0