void gluPickMatrix( GLdouble x, GLdouble y,
GLdouble width, GLdouble height,
GLint viewport[4] )
x, y: center of a picking region in window coordinates.
width, height: width and height of the picking region in window coordinates.
viewport: The current viewport (view window size, as from a glGetIntegerv call).
Use gluPickMatrix to restrict drawing to a small region around the cursor.
Then, enter selection mode (with glRenderMode) and rerender the scene.
All primitives that would have been drawn near the cursor are identified and stored in the selection buffer.
Example:When rendering a scene as follows:
glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(...); glMatrixMode(GL_MODELVIEW); /* Draw the scene */a portion of the viewport can be selected as a pick region by calling gluPickMatrix,
glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPickMatrix(x, y, width, height, viewport); gluPerspective(...); glMatrixMode(GL_MODELVIEW); /* Draw the scene */