views:

193

answers:

3

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?

+2  A: 

Hello flag, 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

Mijat
A: 

Hey, did your code works now? I have now another problem. My objects are separated by colors, like yours. But I tried to put a texture on it. And there’s the problem, the texture does not cover the color. It looks like the texture has some transparency. I tried to use the blending function, but after a few days trying and searching on the net, I’m now frustrated :D

Mijat
i didn't try it jet and if you like you could paste some example code here how to implement it because i think this is interesting for many people. i dont get your problem with textured objects. im doing it this way that normally i render them with the texture and for the one color-picking frame i just dont use the texture..
Sponge
A: 

Hy, I’m sorry but the whole think does not work good enough. Some devices have problems with the OpenGL ES 1.1 Extension. Motorola Milestone and some other Samsung devices. I don’t know if the same problem exists with the 2.1 extension which is also needed to select your object by color. My next try will be to select a object by shooting a pixel into the screen. I’m not sure how this works, but I know that this is a other solution.

Greetings: Mijat

Mijat