Another good way to implement picking in OpenGL is like this:
Draw your scene into the back buffer, using a unique color for each primitive that you want to select. If you are using a 24 bit mode, the colors can simply be #000001, #000002 etc. Turn off lighting, fog etc so that the colors you specify are the exact colors the pixels are going to take.
Don t blit the back-buffer to the screen (don t use glSwapBuffers). Instead, use glReadPixels to read the GL back-buffer into a memory buffer. After this you have a memory bitmap that you can read a pixel value from, corresponding to the location of the mouse on-screen. The color value you read out from this can easily then be mapped to the primitive (since it s going to be #000001, #000002 etc).
Here s some more information on this style of selection. This is what I like to use, since it has one advantage over the GL_SELECTION mode. If the 3D scene is unchanging and the mouse is being moved over it, I can get one copy of the back-buffer and then quickly estimate which entity is under the mouse, by simply referencing the appropriate pixel in my memory bitmap. I don t have to use any GL calls at all until the scene changes. Since my application has a lot of mouse hovering over a 3D scene and I need to quickly know which entity the mouse is floating over, I found this method really fast.