PDA

View Full Version : problems with gluUnproject



vamsee kanth
01-06-2005, 01:39 AM
Hello,

iam using gluUnproject function to retrieve the object coordinates from the screen coordinates.

when i click on a point (2,2,2) i get the output from the function as(2.218335,2.226619,-0.000000)

when i click on a point (3,3,3) i get the output as (2.218335,2.226619,-0.000000)

when i click on a point (4,4,4) i get the output as
(3.079899,3.084041,-0.000000)

when i click on a point (5,5,5) i get the output as
(3.079899,3.084041,-0.000000)

why is there such a discrepancy in the actual values and the returned values of the function??

is it the nature of the function itself or there is some other problem with my code??

i want to retrieve atleast the x-coordinate more or less exactly??

plz help me ,may be with any other possible solution.

thanking you,
vamsee.

mikael_aronsson
01-06-2005, 04:12 AM
Hi !

If you use perspective mode then you need to handle the depth also, remember that you specify the Z value in gluUnproject, OpenGL can't figure that one out on it's own.

If you use orthographic mode you could map it to the correct X,Y coordinates.

Mikael

vamsee kanth
01-06-2005, 06:34 AM
its not about the z value being 0.
its about discrepancy in the values of x and y coordinates.
i want atleast my x-coordinate to be retrieved more or less exactly to the object coordinates.

please help me out.