As part of modifying the GLPaint
, I am trying to add erase functionality where user could select an eraser button and erase the painted area just as painting.
I am trying have a conditional statement within "renderLineFromPoint:(CGPoint)start toPoint:(CGPoint)end"
method so that I could check whether the stroke is for painting or erasing.
For erasing I do not know how to make use of the "start
" and "end
" parameters for erasing. Is there any method call in OpenGL like glClear()
that accepts these two parameter and does erase?
Any pointer will be very helpful. Thank you.
Along the same vein as Erase using brush in GLPaint, you could reuse the
- (void)renderLineFromPoint:(CGPoint)start toPoint:(CGPoint)end
method by having the condition:
if (isEraserBrushType) {
glBlendFunc(GL_ONE, GL_ZERO);
glColor4f(0, 0, 0, 0.0);
} else {
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
[self setBrushColorWithRed:brushColourRed green:brushColourGreen blue:brushColourBlue];
}
above the code:
// Render the vertex array
glVertexPointer(2, GL_FLOAT, 0, eraseBuffer);
glDrawArrays(GL_POINTS, 0, vertexCount);
Note, you'll need to implement isEraserBrushType, and store brushColourRed, brushColourGreen and brushColourBlue somehow.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With