Pick in OpenGl 4 since GL_SELECT seems deprecated

We are migrating from OPENGL 1.1 to OPENGL 4.0. Pick select ( where in the object can be selected and dragged using mouse pointer) is not working. The coding was done using GL_SELECT and GL_RENDER. But OpenGL 4 has not provided any alternative functionality to achieve the pick.

Have seen some approaches like color pick or ray selection but there is no good explanation available.

Can anyone guide if OpenGL 4 has some replacement for Pick functionality.

See:

Alternatively, just do the pick using ray intersect operations on the CPU. For an old app that’s still using GL_SELECT mode, it’ll likely be faster.

The closest thing to glRenderMode in modern OpenGL is transform feedback mode. However, one important difference is that glRenderMode doesn’t report primitives which are outside the clip volume or which are culled due to GL_CULL_FACE, whereas transform feedback mode outputs every vertex emitted by the last stage prior to primitive assembly (vertex shader, geometry shader or tessellation shader).

If you want something like GL_SELECT, you can use transform feedback mode along with a geometry shader which performs culling. However, given the performance implications of both geometry shaders and reverse (GPU->CPU) data flow, you may be better off just performing picking on the CPU.

One advantage of transform feedback mode compared to glRenderMode is that transform feedback occurs alongside rendering rather than replacing it. So you can use transform feedback to capture the transformed vertex positions that are generated during rendering then use the captured data for picking.

One popular solution is to just render the scene to a framebuffer object using an integer format, with the fragment shader outputting gl_PrimitiveID. If you’re picking a single pixel, the framebuffer only needs to be 1x1. If you’re performing mouse-over picking for a static scene, you can render to a full-size framebuffer and read the specific pixel whenever the mouse moves, redrawing only when necessary.

Either way, you have to do more of the process yourself.