android 上的 opengl es 颜色选择不闪烁
我编写了一个对象选择算法,可以根据颜色选择对象。我给每个对象一个唯一的颜色,然后我只需要使用 glReadPixels 方法来检查选择了哪个对象,
这工作正常并且速度非常快,但问题是框架与所有拾取颜色一起显示在屏幕上,因此每次您选择某些内容时,屏幕都会闪烁。
所以我的问题是:如何将所有内容写入正确的显示缓冲区,但不将其显示在屏幕上以避免这些闪烁?
i have written a object selection algorithm which picks the objects by their color. i give every object an unique color and then i just have to use the glReadPixels method to check which object was selected
this works fine and is really fast but the problem is that the frame is displayed on the screen with all the picking-colors so the screen flashes every time you select something.
so my question is: how do i write everything in the correct display buffer but dont display it on the screen to avoid these flashes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您已经启用了双缓冲,则无需创建另一个屏幕外缓冲区。只需跳过缓冲区交换即可。因此,在拾取模式下,您将颜色编码的场景渲染到后缓冲区,使用 glReadPixels 读取单击的像素,清除后缓冲区,然后将普通帧绘制到相同的后缓冲区,然后将其交换到正面。
If you already have double-buffering enabled, there's no need to create another offscreen buffer. Just skip the buffer swap. So, in picking mode, you render your colour-coded scene to the back-buffer, read the clicked pixel with glReadPixels, clear the back-buffer, and then draw a normal frame to the SAME back-buffer, before swapping it to the front.
我们有同样的问题。您需要一个离屏缓冲区。在此缓冲区中,您可以绘制或更改所有项目,而无需将其绘制到屏幕上。
这是一个很好的例子:
http://webcache.googleusercontent。 com/search?q=cache:vdjsjfIiwYwJ:developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FrameBufferObjectActivity.html+opengl+es+android+EGL+offscreen+render& cd=6&hl=de&ct=clnk&gl=de&client=firefox-a
我希望你能使用这个。
亲切的问候:
米贾特
we had the same problem. You need an offscreen buffer. In this buffer you draw or change all items without drawing it to the screen.
Here is an good example:
http://webcache.googleusercontent.com/search?q=cache:vdjsjfIiwYwJ:developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/FrameBufferObjectActivity.html+opengl+es+android+EGL+offscreen+render&cd=6&hl=de&ct=clnk&gl=de&client=firefox-a
I hope you can use this.
Kind Greetings:
Mijat