Name

gluUnProject - map window coordinates to object coordinates

C Specification

GLint gluUnProject(GLfloat winX,
GLfloat winY,
GLfloat winZ,
const GLfloat*  model,
const GLfloat*  proj,
const GLint*  view,
GLfloat*  objX,
GLfloat*  objY,
GLfloat*  objZ);

Parameters

winX, winY, winZ

Specify the window coordinates to be mapped.

model

Specifies the modelview matrix (as from a glGetFloatv call, modelview matrix is queriable in OpenGL ES 1.1, not in OpenGL ES 1.0).

proj

Specifies the projection matrix (as from a glGetFloatv call, projection matrix is queriable in OpenGL ES 1.1, not in OpenGL ES 1.0).

view

Specifies the viewport (as from a glGetIntegerv call, viewport is queriable in OpenGL ES 1.1, not in OpenGL ES 1.0).

objX, objY, objZ

Returns the computed object coordinates.

Description

gluUnProject maps the specified window coordinates into object coordinates using model, proj, and view. The result is stored in objX, objY, and objZ. A return value of GLU_TRUE indicates success; a return value of GLU_FALSE indicates failure.

To compute the coordinates (objX, objY, objZ), gluUnProject multiplies the normalized device coordinates by the inverse of model * proj as follows:


      /      \                /  2 * (winX - view[0])      \
      | objX |                | ---------------------- - 1 |
      |      |                |        view[2]             |
      |      |                |                            |
      |      |                |  2 * (winY - view[1])      |
      | objY |                | ---------------------- - 1 |
      |      |                |        view[3]             |
      |      |   =   INV (PM) |                            |
      |      |                |                            |
      | objZ |                |        2 * winZ - 1        |
      |      |                |                            |
      |      |                |                            |
      |      |                |                            |
      |  W   |                |             1              |
      \      /                \                            /
            

INV denotes matrix inversion. W is an unused variable, included for consistent matrix notation.

See Also

gluProject.

Copyright

Copyright c 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.