Picking in OpenGL

Hi, I have question about picking. Because classic picking in OpenGL is not HW accelerated and new ATI cards have terrible support for this (they even sometimes return bad z depth values…). We are thinking about new way how to pick. Color picking sound fine but there is problem with disable/enable antialiasing because some cards (drivers) can’t change pixelformat on-the-fly and it is impossible in CAD style app to pick invisible elements (believe it or not we need this). Intersection test sounds good but how to pick line graphics? Now I think about use this technique: Do intersection tests on envelopes and then polygon intersection test for triangle based object and for picking line graphics use stencil buffer. My question is if this is a good approach and what do you think about stencil buffer fo picking. As I see it the only problem is number of unique objects in stencil. Thank you for your advice.

When you want to be able to pick invisible objects, you can render to a texture (or the backbuffer WITHOUT swapping the result), when the user clicks, but then you DO render the invisible objects.

I think, when rendering to a texture or renderbuffer, you can “dynamically” decide whether you want multisampling, by creating e.g. a multisampled backbuffer (for the result presented to the user) and a non-multisampled buffer for the offscreen rendering. That should prevent the color-picking approach from problems due to anti-aliasing.