在GLPaint中使用画笔擦除 [英] Erase using brush in GLPaint

查看:149
本文介绍了在GLPaint中使用画笔擦除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为修改 GLPaint 的一部分,我正在尝试添加擦除功能,用户可以选择橡皮擦按钮并像绘画一样擦除绘制的区域。

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.

我正在尝试在renderLineFromPoint:(CGPoint)start toPoint:(CGPoint)end中有一个条件语句方法,以便我可以检查笔画是用于绘画还是擦除。

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.

对于删除我不知道如何使用 start 结束用于擦除的参数。在OpenGL中是否有任何方法调用,如 glClear()接受这两个参数并擦除?

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.

推荐答案

使用GLPaint中的画笔擦除,你可以重复使用

- (void)renderLineFromPoint:(CGPoint)start toPoint:(CGPoint)end 

method by条件:

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];
}

// Render the vertex array
glVertexPointer(2, GL_FLOAT, 0, eraseBuffer);
glDrawArrays(GL_POINTS, 0, vertexCount);

注意,你需要实现isEraserBrushType,并以某种方式存储brushColourRed,brushColourGreen和brushColourBlue。

Note, you'll need to implement isEraserBrushType, and store brushColourRed, brushColourGreen and brushColourBlue somehow.

这篇关于在GLPaint中使用画笔擦除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆