gluUnProject replacement

How do I replace gluUnProject? I dont’t really understand, what the explanation in the Referance Manual means.

You can do the calculation of gluUnProject for yourself, but why do you want to replace it??? gluUnproject maps points in screen coordinates like (1024,768,0) back to object coordinates. As the name already says, it turns projected coordinates back to unprojected coordinates. If you want to do the calculation by hand, check out http://molt.zdv.uni-mainz.de/doc_link/en_US/a_doc_lib/libs/openglrf/gluUnProject.htm#B5C8977891rree

I know what gluUnProject does, but I don’t want to link to the GLU library. My problem is, that I don’t know what

              (  2(winX - view[0])      )
              |  ----------------- - 1  |
              |       view[2]           |

( ) | |
| objX | | 2(winY - view[1]) |
| objY | = INV(PM)| ----------------- - 1 |
| objZ | | view[3] |
( W ) | |
| 2(winZ) - 1 |
| |
( 1 )

means.

Download the source for Mesa or SGI’s OpenGL sample implementation, both includes the source code for GLU so you can have a look at how they did it.

Mikael

The meaning of these symbols is explained under the link I’ve mentioned above.
winX,winY,winZ are the screen coordinates you want to unproject. view[0]…view[3] are the viewport information you can retrieve with glGetIntegerv(GL_VIEWPORT, view).
INV(PM) means the inverse matrix of the concatenation of the projection and the modelview matrix. It’s just some boring calculation. The tricky part is that you need an algorithm for matrix inversion, but these can be easily found by ‘googling’.

[This message has been edited by mako (edited 08-25-2003).]

[This message has been edited by mako (edited 08-25-2003).]