Search code examples
iosxcodeopengl-esbrush

IOS: GLPaint erase an imageview


I'm usin GLPaint to paint inside an UIView, but not I want to using an erasing brush. I know that the code to have a erase brush is:

glBlendFunc(GL_ONE, GL_ZERO);
glColor4f(0, 0, 0, 0.0);

but if I put in my UIView an imageView I want to delete it also...is it possible?


Solution

  • There are several possible ways to do this, but here's what I would try first. Inside your PaintingView, draw a textured quad with the image textured onto it. Then draw a textured quad over that with your paint strokes on it. Set the blending mode to the normal over mode (glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);). Then wherever the source alpha is 0, you'll see the textured quad with the image through it.