Color selection on android without screen flickering

I wrote an object selection algorithm that selects objects based on their color. I give each object a unique color and then I just need to use the glReadPixels method to check which object was selected.

this works fine and very fast, but the problem is that the frame is displayed on the screen with all the colors selected so that the screen blinks every time you select something.

so my question is, how do I write everything in the correct display buffer, but not display it on the screen to avoid these flashes?

+2


a source to share


2 answers


If you already have double buffering enabled, there is no need to create another offscreen buffer. Just skip the clipboard. So, in select mode, you provide your scene color-coded to the back buffer, read the selected pixel from glReadPixels, clear the back-buffer, and then render a normal frame in ONE back-buffer before replacing it with the front.



+2


a source


we had the same problem. You need an off-screen buffer. In this buffer, you draw or change all elements without drawing them to the screen.

Here's a 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



Hope you can use this.

Cheers: Mijat

+2


a source







All Articles