1GLUPICKMATRIX(3G) GLUPICKMATRIX(3G)
2
3
4
6 gluPickMatrix - define a picking region
7
8
10 void gluPickMatrix( GLdouble x,
11 GLdouble y,
12 GLdouble delX,
13 GLdouble delY,
14 GLint *viewport )
15
16
18 x, y Specify the center of a picking region in window coordinates.
19
20 delX, delY
21 Specify the width and height, respectively, of the picking region
22 in window coordinates.
23
24 viewport
25 Specifies the current viewport (as from a glGetIntegerv call).
26
28 gluPickMatrix creates a projection matrix that can be used to restrict
29 drawing to a small region of the viewport. This is typically useful to
30 determine what objects are being drawn near the cursor. Use
31 gluPickMatrix to restrict drawing to a small region around the cursor.
32 Then, enter selection mode (with glRenderMode) and rerender the scene.
33 All primitives that would have been drawn near the cursor are identi‐
34 fied and stored in the selection buffer.
35
36 The matrix created by gluPickMatrix is multiplied by the current matrix
37 just as if glMultMatrix is called with the generated matrix. To effec‐
38 tively use the generated pick matrix for picking, first call glLoadI‐
39 dentity to load an identity matrix onto the perspective matrix stack.
40 Then call gluPickMatrix, and finally, call a command (such as
41 gluPerspective) to multiply the perspective matrix by the pick matrix.
42
43 When using gluPickMatrix to pick NURBS, be careful to turn off the
44 NURBS property GLU_AUTO_LOAD_MATRIX. If GLU_AUTO_LOAD_MATRIX is not
45 turned off, then any NURBS surface rendered is subdivided differently
46 with the pick matrix than the way it was subdivided without the pick
47 matrix.
48
50 When rendering a scene as follows:
51
52 glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(...);
53 glMatrixMode(GL_MODELVIEW); /* Draw the scene */
54
55 a portion of the viewport can be selected as a pick region like this:
56
57 glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPickMatrix(x, y,
58 width, height, viewport); gluPerspective(...); glMatrixMode(GL_MOD‐
59 ELVIEW); /* Draw the scene */
60
62 glGet(3G), glLoadIndentity(3G), glMultMatrix(3G), glRenderMode(3G),
63 gluPerspective(3G)
64
65
66
67
68 GLUPICKMATRIX(3G)