Selection the 3d objects OpenGL ES 1.1

Hi there…

How can I select 3d objects in OpenGL ES 1.1 ?

My application is for iPhone OS and it works in perspective
3d and when the user touch in the screen any objects must
be select or not. The application have boxes, spheres, teapots, tubes,
torus and others geometric objects.

In OpenGL I have the solution but in OpenGL ES 1.1 many functions are not suported.

look de code in OpenGL below.

unsigned int obj_sel(const int max, unsigned int buffer[])
float menor_z = 1.0;
unsigned int menor = 0;
unsigned int *ptr = buffer;

for (int i = 0; i < max; ++i)
*ptr++; float zmin = (float)*ptr++ / 0xffffffff; *ptr++;
if (zmin < menor_z){ menor = *ptr; menor_z = zmin;} ptr++;

return menor;

unsigned int select_object()
int viewport[4];
unsigned int select[3000];

glSelectBuffer(3000, select); glRenderMode(GL_SELECT);
glInitNames(); glPushName(0); glMatrixMode(GL_PROJECTION);

glGetIntegerv(GL_VIEWPORT, viewport); glLoadIdentity();
gluPickMatrix((double)x, (double)viewport[3] - y, 1.0, 1.0, viewport);
gluPerspective(45.0, (float)480 / (float)320, 1.0, 1000.0);
glMatrixMode(GL_MODELVIEW); draw_scene(true); glMatrixMode(GL_PROJECTION);

glMatrixMode(GL_MODELVIEW); glFlush(); int max = glRenderMode(GL_RENDER);
return obj_sel(max, select);

it not work very well in OpenGL ES 1.1 because
glSelectBuffer(), glRenderMode(GL_SELECT),
glInitNames(), glPushName() and glLoadName() are not supported

I have finding in web sites for (picking, selection in OpenGL ES…)
but no results. Someone know where can I find it ?
maybe books, web sites, links or tutorials… any help will be usefull… thanks to all…

I believe that the usual way to accomplish this is by rendering each “object” in a different solid color, then calling glReadPixels() in the area where you want to pick the object and the which color(s) you get in that area will indicate the objects that are visible.

The other way to do this involves ray casting, which is probably overkill for what you want.

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