View Full Version : Draw hole in texture
02-21-2010, 04:30 PM
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?
02-21-2010, 05:00 PM
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?
02-21-2010, 06:23 PM
alphatest or stencil
02-21-2010, 06:59 PM
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!
02-21-2010, 07:00 PM
^^" There are a billion tutorials and docs on those online.
02-21-2010, 07:53 PM
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...
02-22-2010, 01:35 AM
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 ?
02-22-2010, 09:08 AM
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:
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?
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.