[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
OpenGL 1.2 for AIX: Reference Manual

gluPickMatrix Subroutine

Purpose

Defines a picking region.

Library

OpenGL C bindings library: libGL.a

C Syntax

void gluPickMatrix( GLdouble x, 
   GLdouble y, 
   GLdouble delX, 
   GLdouble delY, 
   GLint viewport[4])

Description

The gluPickMatrix subroutine creates a projection matrix that can be used to restrict drawing to a small region of the viewport. This feature is useful to determine what objects are being drawn near the cursor. Use gluPickMatrix to restrict drawing to a small region around the cursor. Then, enter the selection mode (with the glRenderMode subroutine) and re-render the scene. All primitives that would have been drawn near the cursor are identified and stored in the selection buffer.

The matrix created by the gluPickMatrix is multiplied by the current matrix just as if the glMultMatrix subroutine is called with the generated matrix. To effectively use the generated pick matrix for picking, first call the glLoadIdentity subroutine to load an identity matrix onto the perspective matrix stack. Then, call gluPickMatrix, and finally, call a subroutine (such as the gluPerspective subroutine) to multiply the perspective matrix by the pick matrix.

When using gluPickMatrix to pick non-uniform rational B-splines (NURBS), be careful to turn off the NURBS GLU_AUTO_LOAD_MATRIX property. If GLU_AUTO_LOAD_MATRIX is not turned off, any NURBS surface rendered is subdivided differently with the pick matrix than the way it was subdividied without the pick matrix.

Parameters

x, y Specify the center (in window coordinates) of a picking region.
delX, delY Specify the width and height (in window coordinates), respectively, of the picking region.
viewport Specifies the current viewport (as from a glGetIntegerv call).

Examples

When rendering a scene as in the following example:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(...);
glMatrixMode(GL_MODELVIEW);
/* Draw the scene */

a portion of the viewport can be selected as a pick region as follows:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPickMatrix(x, y, width, height, viewport);
gluPerspective(...);
glMatrixMode(GL_MODELVIEW);
/* Draw the scene */

Files

/usr/include/GL/gl.h Contains C language constraints, variable type definitions, and ANSI function prototypes for OpenGL.

Related Information

The glGet subroutine, glLoadIdentity subroutine, glMultMatrix subroutine, glRenderMode subroutine, gluPerspective subroutine.

OpenGL Overview.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]