gluUnproject. Is it pants?

Hi All

Ive set up a scene comprising some geometric primitives. The near plane is set at a distance of 500 units, the far plane 5000 units. All the primitives are completely visible, ie they are within the bounding volume

Im using gluUnproject to get the real world point of each screen pixel.

Why am I getting pixels with z-coords of only 100. How is this possible if the near plane is set at 500. Surely all visible pixels should have a miunimum z-coord of 500 units.

Any ideas what is happenning? Ive checked all the obvious stuff such as checking for background pixels and rembering about the difference between Windows co-ords and OpenGl coords for gluUnproject.

cheers

I think you expect something from the function which it is not able to do. gluProcet and unproject just procets from window space to opengl space and vice versa.
It does not take into account wether some pixel has some depth or whatever. You need to specify the full 3d coordinates to get reasonable values back.

gluUnproject will convert a supplied screen-z value in the range [0.0 - 1.0] to the specified near-far range [500 - 5000]. However, that range is NOT in the ‘real-world’ yet, but in an intermediate stage: between the modelview and the projection stage.
Depending on your camera position and its orientation, points ‘on’ the near plane can be anywhere in the real-world.

HTH

Jean-Marc

thanks. However Im still completely baffled.

For a pixel with a z-depth less than 1, Im getting these 3 co-ordinates from gluUnproject

X = -40.8
Y = 144.5
Z = 100.9

The near plane is at 450, far plane at 5000.

So how the hell does that make sense?

The real world viewpoint is at point (0,0,0) if that helps.

cheers

[This message has been edited by rangers99 (edited 05-06-2002).]