Draw hole in texture

Hey everyone!

I have been trying to figure out the best way to solve this problem and keep coming up with nothing…

I want to draw a circle hole into a texture with another texture(mask). This hole needs to be transparent so the background image shows though the hole.

Whats the best and fastest way to cut out that hole?

Example

Maybe it’s easier if I ask the question differently:

Whats the best way to subtract texture B texture from texture A leaving a hole in texture A?

Thanks!

alphatest or stencil

Would you mind elaborating on these a little? I am using OpenGL ES 1.1 and speed is an issue. I’ve heard alpha testing can be slow but stencil might be better.

If you could provide some more information I would greatly appreciate it!

^^" There are a billion tutorials and docs on those online.

Is there any other way to achieve this? Stencil is not supported on my hardware. I’m not clear on how alpha test can throw away pixel data from the image…

Thanks again!

Or multitexture with an alpha mask.
Or if the cutting is static, just add correct alpha data in the texture.
Can you do multitexture at least ?

Hi ZbuffeR,

Thanks for your reply. The cutting is not static it will be based on user input. One clarification to the example above, the background image will remain unchanged and a blank texture will be the one the holes:

Drawing order

  1. background
  2. blank texture
  3. alpha mask (position based on input)

I think this should work. Multi-texturing is available but I cannot seem to get the texture combiners set right. Using this method, is it possible to cut a hole in the blank texture so background shows though?

Thanks!

Is there some reason you HAVE to use textures to accomplish the desired effect? You could simply read in the image and display it using DrawPixels. Then draw some white polys over it in the shape of a rectangle with a hole cut out of it. That way you would not use textures, stencils, or even z-buffering.