I am drawing a mesh of triangles using glDrawElements and would like to be able to pick/select a triangle using the mouse click. The mesh of triangles can be very big.
In fixed-function OpenGL there is the possibility of using GL_SELECT: http://content.gpwiki.org/index.php/OpenGL:Tutorials:Picking .. However I am only interested in using OpenGL core profile.
Another possibility would be to use 'color coding':
http://www.lighthouse3d.com/opengl/picking/index.php?color1
http://www.opengl.org/resources/faq/technical/selection.htm
.. but as far as I know its not possible to indicate per triangle information yet when using glDrawElements?
Finally I could do CPU based picking by shooting a pick ray through the mouse location, but this would be quite slow since I guess I would have to transform the triangles on the CPU, so I would prefer a GPU based solution.
Does anyone have a suggestion on what is the best way do picking when using glDrawElements in OpenGL core profile?