You’ll probably need to take the near plane distance into account, if you’re looking for the world position coinciding with the camera position, say, with a winz of 0.
You’ll probably need to take the near plane distance into account, if you’re looking for the world position coinciding with the camera position, say, with a winz of 0.
Yes, that’s what I’m doing; the third parameter in gluUnproject is zero (WinZ) in the example I posted before
gluUnproject(mouseX, height - mouseY, 0, ...)
But I’m getting some difference in Z. It looks like the camera is a little behind the frustrum but I don’t know if it’s ok.
How do you set up modelview and projection matrices?
gluUnproject returns coordinates in object space. You may have to transform again these coordinates by the modelview matrix to get coordinates in eye space.