help w/ selection of front/nearest polygon only

Hey all,

I have a geometric model that is drawn with gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE), which means that the entire object looks like a wireframe of triangular mesh. My problem is that when I select a polygon in the mesh, I have several hit records in my selection array and I really only want to be able to select the polygon closest to the camera (the one in front) and not behind, yet still be able to show visually everything behind the one in the front (just never select anything from behind).

Any ideas what I need to do to accomplish this? Any help much appreciated.

Something I tried that almost worked.

I was able to do what I wanted using glCullFace(GL.GL_FRONT), so my picking worked on only the front face (or outside) of the triangles that were closest to the camera, but the probem is that I can’t see all the sides of my model. My render mode is GL.GL_MODELVIEW.

So if I have a box, I can only see the sides facing me and not the sides in the back. All my models are wireframe so without culling, I can see it as I want, but then I’m also able to select polygons in the back if I’m not careful and I’m trying to only get the ones in the front.

A simple hacky solution is to enable the glCullFace(GL.GL_FRONT) when drawing to the selection buffer and disabling it when drawing to the screen :slight_smile: