Mapping Screen Coordinates to a Parallel Plane

Hey, I’m been slowly building my first OpenGL application with minor problems here and there but finally I ran into something which I need to ask for help about.

When I get the screen coordinates from the mouse functions how would I go about mapping them to a coordinate on a plane parallel to the screen.

The reason is so I can make simple buttons just by mapping screen coordinates to the 2-d plane where my buttons are then check to see if the coordinate is within the button’s area.

  • Thanks in Advance.

Do your mean
mouse move x-y plane
but make a point on or parallel to it
somewhere in z?

if yes then try glutKeyboardFunc(uchar key,int,int);
to set switctc key (a-> z++,z z–)

I hope it help full

I mean like given some “2D” elements on a plane parallel to the scene I want to be able to map screen coordinates to those element’s coordinates.

These elements could be at any given z level.

Does it matter what the view angle is? Like when you set:
“gluPerspective([angle], [ratio], [zNear], [zFar]);”

I thought it would be simple enough to just offset the coordinates based on the relative origin, then multiply the result based on the z-distance and view angle.

Such that if the screen is 200 by 200, and you active the mouse func at point 100, 100 in the 3-d scene isn’t that the center? So for me the center of my plane or 0, 0?