View Full Version : reading coordinates into an array

09-29-2000, 06:28 AM
Hi all, I'm a newbee to the area of OpenGl.
I have a question, how do I get the coordinates of a point that a user left mouse clicks on in a window? I basically need to store an arbitrary number of coordinates like this into an array to later create a polygon from it. Thanks

09-29-2000, 07:12 AM
This sort of thing is extremely hard, mostly because the user can only move the mouse in 2 dimensions, but they are trying to manipulate a 3D enviroment, what you should do is something like this: work out a plane which is perpendicular to the camera direction and goes through the origin. e.g. if the camera is looking down the -z axis then you should use the XY plane. The plane can be calculated with various mathematical tecniques (see some maths books not me).
Then you need to set up a mapping between window coordinates (the pixel the user clicked on) and OpenGL points (a point somewhere on the plane you calculated.

09-29-2000, 07:18 AM
What OS and language? Microsoft Windows and C(++)? If so, there are a few ways, to get the mouse coordinates. You can either get them from the lParam argument of the WM_MOUSE_LBUTTONDOWN or WM_MOUSE_LBUTTONUP message, or you can poll the mouse itself using Win32 calls, or DirectInput.
Then you'll have to map those 2D coordinates to your OpenGL coordinate system, if they are not the same.

[This message has been edited by DFrey (edited 09-29-2000).]

09-29-2000, 10:04 AM
I'm using Visual C++ 6, and Windows NT.
I just need to create a 2D polygon from a
series of mouse clicks in a window, such that
a left mouse click represents a vertex of
the polygon, when the user is done inputting
vertices he right clicks the mouse and the
polygon edges are then drawn to connect these