Eraser in OpenGL ES iphone

寵の児 提交于 2019-12-06 08:59:21

问题


i have two images which are overlapping on each other.(the way in which cards are placed on top of each other)

now if i move my finger over the top most image that portion of the image should become transparent.(opacity of that part should become 0).

i am new to OpenGL ES development.

kindly help me out or give me any suggestion to complete this functionality.

Thanks in advance


回答1:


You're going to need render-to-texture using Framebuffer Objects (FBOs). Render to the desired texture, but only to the alpha channel, which is done using glColorMask (With it you can mask all color channels except alpha), and then draw the pattern into the alpha channel, setting alpha to 0.0, then display the textures as normal.




回答2:


I just did something similar, and I found a solution in GLBlending:

if (eraseMode) {
    glBlendFunc(1.0,0.0);
}
else {
    glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
}

Some cosmetics are needed around this, but it's a simple solution that fits basic needs.



来源:https://stackoverflow.com/questions/3439616/eraser-in-opengl-es-iphone

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!