How pickup object in opengl ES?

In opengl can use gluUnproject or GL_SELECTION render mode.
But in ES not support .
How pickup object in opengl ES?
Thanks!

a.) Tranform your mouse coordinates into a ray in world coordinates and determine ray intersections with your objects.

b.) Emulate what picking does: Render the image flat to a bitmap surface (choosing a distinct color for each object), then read out the pixel corresponding to your selection to derive the visible object.

  • HM

What are the operations you need to do to convert screen coords into your world coord. system?

I already did the painter’s method in my game, because there were not too many objects in my world. I am just wondering specifically how you do ray picking.

In opengles you set the color by using 4 floats clamped to [0,1]
But when you read back the colors of the picked pixel you get 4 unsigned bytes.
How do you convert those byte values to the float values?
divide them by 255?

Thx

You can also specify colors using 4 bytes with glColor4ub(v) or a color array using type GL_UNSIGNED_BYTE.

But when you read back the colors of the picked pixel you get 4 unsigned bytes.
How do you convert those byte values to the float values?
divide them by 255?

Yes. But keep in mind that you may lose precision in the rendering process and the byte values could come from an RGB565 framebuffer.

Thx for reply.
However i dont find the glColor4ub(v) in openglES api.
I will try with the color array.

Regards.

Finally got it!
While glColor4ub(v) does not appear in the reference manual:
http://www.khronos.org/opengles/documen … index.html
It does in the header file:
http://www.khronos.org/registry/gles/api/1.1/gl.h

glColor4ub has been added in OpenGL ES 1.1. The v version is not there, that was a mistake in earlier diff specs.

I’ll file a bug report for the missing description in the reference manual.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.