Yes I have just seen that "selected mode" is not available in OpenGL
ES.
So, I'm trying to follow the other ways, starting from "color-
solution", that seems the simplest. But I already get a problem... :(
At every frame I'd draw many markers (every marker has different
coordinates) in the scene and I do it in one draw function, something
like this:
public void onDrawFrame(GL10 gl) {
float colorCount = 0.0f;
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glLoadMatrixf(matrix.val, 0);
for(int i = 0; i<markers.size(); i++){
gl.glColor4f(colorCount, 0, 0, 1);
markers.get(i).draw();
colorCount++;
}
}
but unfortunately it doesn't work. The color remains always white
(0,0,0,1) in RGBA. I'm confused. I know it may be a stupid question,
but I'm a beginner in OpenGL.
On 29 Nov, 16:59, Phil Endecott <[email protected]> wrote:
> > I've read about "picking" in OpenGL
>
> Beware that "selection mode" is not available in OpenGL ES.
>
> > I want to understand if there are other solutions.
>
> You have various options, but none is simple:
>
> 1. unproject from the (x,y) screen coordinates to a ray in model
> space, and work out which object(s) intersect that ray.
>
> 2. unproject from the (x,y) screen coordinates and the corresponding z
> coordinate from the depth buffer to a point in model space, and work
> out which object includes that point.
>
> 3. Draw your entire scene a second time into an off-screen framebuffer
> (possibly at lower resolution), but instead of using the objects'
> actual textures or colours, use a unique colour for each object. Then
> just look at the colour in this framebuffer at the selected (x,y)
> point, and you can decode the corresponding object.
>
> These are all general techniques. Sometimes your application will
> have characteristics that let you do something simpler, e.g. a
> constrained projection or object layout.
>
> Good luck!
>
> Phil.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en