Using Android OpenGL ES 1.1 (HTC Desire) ...
The problem I have in general is this:
I have various 3D objects created in a complex scene. I want to check if the user clicked on a specific object. This object may be partially hidden and therefore may seem like almost any form of scene. I want the object to be โselectedโ if the user clicks on the part of the object that is visible in the scene. This means that I cannot use vector-based calculations to intersect objects, because they could not easily account for hidden areas of the object.
So, I came up with an idea ...
I set the stencil buffer so that wherever the object was visible, the stencil buffer was filled for 1 s, and everywhere in the stencil buffer it was 0. When the user clicks on a specific pixel in the scene, I just need to check the stencil buffer to see whether it is 1 or 0, which indicates whether the object was clicked or not.
This works fine on PC, but on Android OpenGL ES 1.1 it seems that I cannot read from the stencil buffer using glReadPixels (), since 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 to determine if my object was clicked?
Many thanks
chris source share