Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erase using brush in GLPaint

Tags:

iphone

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.

like image 962
dinesh Avatar asked Oct 29 '10 03:10

dinesh


1 Answers

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.

like image 173
zlog Avatar answered Oct 16 '22 03:10

zlog