Mouse position openGL

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???

have you tried glUnProject for converting mouse-ccordinates to world-coordinates? See the doc for more infos. or have i misunderstood you?

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.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.