PDA

View Full Version : mouse position openGL



01-05-2001, 10:52 AM
so I've got this little game I"m working on but the problem is the macintosh toolbox routine GetMouse returns an integer Point structure...two numbers between 0 and 600 and 800(800 x 600 screen) but when you use the openGL calls they do things in terms of floating point...and there is the glVertex3i but the numbers are still nasty....up till now I've been multiplying and adding arbitrary values to convert where the mouse is in pixels into the floating points...I'm sick of it. I'm sure there is some function that truly specifys what the perspective matrix does to the frame buffer or whatever...i assume that -1.0f and 1.0f in the x plane are the left and right sides of the screen while z is equal to 0.0f. but what about when z = -5.0f or something???

sth
01-07-2001, 08:05 AM
have you tried glUnProject for converting mouse-ccordinates to world-coordinates? See the doc for more infos. or have i misunderstood you?

01-07-2001, 09:24 AM
nevermind, i figured it out...i hate using all that glu stuff...to all who are interested...to reverse the perspective on something(in particular mouse coords) do this for x: ((mousepositionX * 2 / screenwidth) - 1) * -ztranslation * (2/3)....for y its just the same but screenwidth is obviously screenheight and you add instead of subtracting 1....you may need to alter this to make it fit your particular situation.