Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Transforming Coordinates

The OpenGL Utility library (GLU) provides several commonly used matrix transformation functions. You can set up a two-dimensional orthographic viewing region with gluOrtho2D, a standard perspective view volume using gluPerspective, or a view volume that is centered on a specified eyepoint with gluLookAt. Each of these functions creates the desired matrix and applies it to the current matrix using glMultMatrix.

The gluPickMatrix function simplifies selection of a picking matrix by creating a matrix that restricts drawing to a small region of the viewport. If you re-render the scene in selection mode after this matrix has been applied, all objects that would be drawn near the cursor will be selected, and information about them will be stored in the selection buffer. For more information about selection mode, see "Performing Selection and Feedback" Performing Selection and Feedback.

To determine where in the window an object is being drawn, use gluProject, which converts the specified object coordinates objx, objy, and objz into window coordinates using modelMatrix, projMatrix, and viewport. The result is stored in winx, winy, and winz. If the function succeeds, the return value is GL_TRUE. If the function fails, the return value is GL_FALSE.

The gluUnProject function performs the inverse conversion: it transforms the specified window coordinates winx, winy, and winz into object coordinates using modelMatrix, projMatrix, and viewport. The result is stored in objx, objy, and objz. If the function succeeds, the return value is GL_TRUE. If the function fails, the return value is GL_FALSE.


  

Community Additions

Show:
© 2015 Microsoft