Producing eraser effects using libgdx and OpenGL ES

谁都会走 提交于 2019-11-30 05:06:35

Could you use FBO's and a stencil buffer?

Setup an FBO for your "pink" layer and a stencil buffer for it. On touch down, draw your touch as a mask to the pink FBO's stencil buffer. Now when you draw the pink FBO, the areas you touched wont be rendered so you'll be able to see the background FBO behind it.

This link http://www.opengl.org/archives/resources/faq/technical/rasterization.htm, section 14.050 tells you how to setup a stencil buffer:

You can set up OpenGL state as follows:

glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 0x1, 0x1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);

Subsequent rendering will set a 1 bit in the stencil buffer for every pixel rendered.

You may have to fiddle with things so your masking comes out the right way (masks where you did touch, not where you didn't.)

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