opengl es color picking on android without screen flashing
-
02-10-2019 - |
Question
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?
Solution
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.
OTHER TIPS
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.
I hope you can use this.
Kind Greetings: Mijat