Hello to everyone !
I like to know how I can easily convert the 2D coordinates of the mouse to 3D coordinates. Does anyone know something about this ?
Hello to everyone !
I like to know how I can easily convert the 2D coordinates of the mouse to 3D coordinates. Does anyone know something about this ?
Use gluUnProject.
The win-Z coordinate (third parameter I think) can be a problem. Some people use glReadPixels to read the Z-buffer value at the mouse posision and pass it to gluUnProject.
win-z should be between 0 and 1 inclusive. I use this and get no problems.
However, if you changed glDepthRange the limits will be adjusted. If you haven’t then stick to 0-1 and you should be fine.