Using Android OpenGL ES 1.1 (HTC Desire)...
The problem I have in general is this:
I have various 3D objects rendered in a complex scene. I want to check if the user has clicked on a particular object. This object may be partially hidden and therefore may appear as almost any shape in the scene. I only want to allow the object to be "selected" if the user clicks on a part of the object that is visible in the scene. This means that I cannot use vector-based calculations for the object intersection since these could not easily take into account the hidden areas of the object.
So I came up with an idea...
I set up the stencil buffer such that wherever the object was visible the stencil buffer was filled with 1s and everywhere else in the stencil buffer is 0. When the user clicks on a particular pixel in the scene I just need to check the stencil buffer to see if it contains a 1 or 0 which indicates if the object was clicked or not.
This works perfectly on a PC, but on Android OpenGL ES 1.1 it seems that I cannot read from the stencil buffer by using glReadPixels() as GL_STENCIL_INDEX is not supported.
Does anyone know if there is a way to read this 0/1 from the stencil buffer? Or can anyone think of a better algorithm for determining if my object has been clicked?
Many thanks