A hard projection question

OK I’ve been having real troubles here! I’ve got an OpenGL app at the moment, and I have a scene graph that I’ve added Raytacing code to. I know that you have to make a ray starting at the viewer and passing each pixel, but how do I get the screen coordinates as world coordinate? Bearing in mind all I know about my camera is its translation, rotation, field of view, aspect ratio and near and far clipping planes (it’s a projection camera). I cannot find any advice on getting the screen coords for a camera that works with ‘gluPerspective’, does anyone have any ideas???

You see a rectangle at the near plane. This rectangle maps directly to screen pixels. If you look at the documentation for gluPerspective and glViewport, some simple algebra and trigonomtry should give you the equations you need.

Is gluUnProject(…) what you are looking for? It undoes all the transformations and stuff.