Hi, I'm trying to perform OpenGL picking (i.e. answer the "on which object did the user click?" question). I googled it and found a few different techniques, but none is ok for me
- checking the pixel color with glReadPixels: I'm using textures so it's not suitable - checking the pixel alpha with glReadPixels: I'm using alpha for blending so it's not suitable - building a ray and checking collisions: ouch!, i'd prefer to not go into that... - glRenderMode(GL_SELECT): Not supported in OpenGL ES I have been thinking about checking the stencil buffer value. I don't use it for its usual purpose, so each of my objects could write its ID in it (I have less than 255 objects). The problem is that I don't manage to read the stencil buffer value using glReadPixels. No problem for RGBA, but I don't manage to make it working for the Stencil value. Here is my code: ByteBuffer bb = ByteBuffer.allocateDirect(4); bb.order(ByteOrder.nativeOrder()); bb.position(0); glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, bb); Log.d(TAG, "color is R"+ bb.get() + " G" + bb.get() + " B" + bb.get() + " A" + bb.get()); // ---> This is working fine, I can read RGBA correctly bb.position(0); glReadPixels(x, y, 1, 1, GL11ExtensionPack.GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, bb); Log.d(TAG, "stencil is "+ bb.get()); // ---> This is not working, looks like it isn't doing anything since I still get the R value in the buffer... I'm sure the stencil buffer is up and running because I managed to use it for some clipping. It is configured to 8bits using setEGLConfigChooser(8, 8, 8, 8, 8, 8). Is it a limitation of the platform or is it me not doing it the right way? (I didn't find any actual example of reading the stencil buffer) Thanks in advance. -- 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 To unsubscribe from this group, send email to android-developers+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

