gluPerspective and windows coordinates

Hello fellow developers,
I am working on a piece of software that already allows the evaluation and drawing of functions, rendered in a gluPerspective world.
My problem is that I need to know the openGL world coordinates when I click on the application’s window. To keep things simple, lets say that I am only interested in the x axis (taking into accound rotation around the y axis). Could you offer a transformation?
Thanks in advance

gluUnProject does exactly what you’re asking for.

Thanks a lot!