生产使用libgdx和OpenGL ES橡皮擦影响 [英] Producing eraser effects using libgdx and OpenGL ES

查看:532
本文介绍了生产使用libgdx和OpenGL ES橡皮擦影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑用于说明以下图片:

Please consider the following images for the illustration:

起初我充满整个屏幕/舞台单个图像,直到屏幕变成粉红色。粉红色的每个斑点是我添加到舞台的个人形象的演员。

Initially I fill the whole screen/stage with individual Images until the screen turns pink. Each blob of pink colour is an individual Image actor that I add to the stage.

现在我想,每一个用户触摸屏幕时,它删除了图片,其中触摸事件发生的一部分,这样的方式来实现触地得分的方法。然而,触摸事件不应影响其他图像/演员/ TextureRegions是背后或高于粉红色斑点的演员。我怎么在使用OpenGL ES libgdx实现这一目标?请帮我在这方面的工作。

Now I want to implement the touchDown method in such a way that each time the user touches the screen, it erases a part of that Image where the touch event took place. However, that touch event should not effect other Images/actors/TextureRegions that are behind or above the pink blob actors. How am I supposed to achieve this in libgdx using OpenGL ES? Please help me in this regard.

我发现这个链接,说明如何修改TextureRegion,但我不知道我会如何实现使用该技术我的问题解决方案,在这个博客中解释。 <一href="http://blog.gemserk.com/2012/01/04/modifying-textures-using-libgdx-pixmap-in-runtime-explained/">Here是链接

I found this link which explains how to modify a TextureRegion but I don't know how I am going to achieve solution for my problem using the technique explained in this blog. Here is the link

推荐答案

你能使用FBO的和模板缓冲?

Could you use FBO's and a stencil buffer?

设置一个FBO为你的粉红色的层,它的模板缓存。在触摸下来,画你的触摸作为面膜粉红色FBO的模板缓存。现在,当你画的粉红色的FBO,感动你不会渲染的区域,所以你可以看到它后面的背景FBO。

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.

此链接 http://www.opengl.org/archives/资源/ FAQ /技术/ rasterization.htm ,部分14.050告诉您如何设置模板缓存:

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

您可以设置OpenGL的状态如下:

You can set up OpenGL state as follows:

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

     

后续渲染将设置1位为每一个模板缓冲区   像素渲染。

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.)

这篇关于生产使用libgdx和OpenGL ES橡皮擦影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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