i have written a object selection algorithm which picks the objects by their color. i give every object an unique color and t开发者_StackOverflowhen 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?
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.
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
精彩评论