Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: mouse position openGL

  1. #1
    Guest

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

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    hamburg, germany
    Posts
    1

    Re: mouse position openGL

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

  3. #3
    Guest

    Re: mouse position openGL

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •