View Full Version : Prblems with Mouse Conversion ( win -> x,y plane)???

08-22-2002, 07:45 AM
alright, im making an RTS game using GLUT right now. But i discovered that to be able to click on a unit i need to kno the mouses coordinates in a cartesean plane, not the windows typical coordinate system (which goes top left to bottom right) i tried writting a class to make my own mouse, which was actually just a 3D shape wich moved in conjunction with the mouse movements, but there were way too many bugs. So if anyone knows a simpler equation, or possibly a formula to convert windows coordinates to cartesean plane coordinates i could use the help. THNX

08-22-2002, 08:28 AM
look up gluProject and gluUnproject


08-22-2002, 02:57 PM
Originally posted by coredump:
look up gluProject and gluUnproject


OK i found that command and this is what it looks like:

GLint gluProject(GLdouble objx, GLdouble objy, GLdouble objz, const GLdouble modelMatrix[16],const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *winx, GLdouble *winy, GLdouble *winz);

I DONT GET IT. How would i use this. It returns whether it failed or succeded. Does it reassign the variables u pass to be what u want( ie if i give it the mouse corrds will it assign the object coords to objx, objy, obz ). Ugh this is confusing

08-23-2002, 04:24 AM
Read up on pointers in your favorite C/C++ source. Then you will come to realize that the GLdouble* parameters on that function are likely to be OUTPUT parameters.