# Can anyone explain gluProject

This topic is 4616 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

int gluProject(GLdouble objx, GLdouble objy, GLdouble objz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *winx, GLdouble *winy, GLdouble *winz) the last three parameter is winx,winy,winz the API doc say it is screen coordinate of point, but in screen, we only need winx and winy why there is winz here, screen is a 2D plane

##### Share on other sites
Well I can't give you a real answer, but since the winx winy and winz parameters are pointers, why not give the function a pointer for winz and see what it spits out? You might be able to make sense of it, if you haven't tried already. Sorry but thats all I can offer. Good luck. :)

##### Share on other sites
A vector transformation is done as
v' := P * M * v
where P is the PROJECTION matrix and M is the MODELVIEW matrix.

Then (stolen from man page)
winX := view(0) + view(2) * (v'(0) + 1)/2
winY := view(1) + view(3) * (v'(1) + 1)/2
winZ := (v'(2) + 1)/ 2

So, winZ is a normalized depth co-ordinate, suitable to be compared with a stored value from a depth buffer. That is just a necessity for a way (typically done by hardware) to let surfaces in the foreground hide surfaces in the background (if the set-up is chosen so). It is done well in the "pixel domain", since it allows the depth buffer to show the same resolution as the frame buffer does, so that each pixel has a depth value attached. So you could understand the depth buffer as the 3rd spatial dimension of your window.

EDIT: As soon as you try to do the opposite operation (gluUnproject) you'll see that in general not a location in 3D space but infine many locations are valid for a single pixel, where all locations are ordered so that they build-up a ray. Only if supplying a depth value (say a travel distance along the ray's track) you are able to defined a single locations.

##### Share on other sites
Quote:
 Original post by xlvectorwhy there is winz here, screen is a 2D plane

Without the Z component, how would you do Z-buffering?

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633388
• Total Posts
3011614
• ### Who's Online (See full list)

There are no registered users currently online

×