[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] MacOS/PyGame/PyOpenGL mouse inversion



On 1/17/07, Chris Ashurst <CAshurst@xxxxxxxx> wrote:
I think on all systems (and if you're used to getting mouse x/y coordinates
via the SDL side of pygame) the mouse is "flipped" when you use OpenGL.

People with more experience with OpenGL can probably clarify, but I have hit
this same issue before, too. I think the x coord turned out to be fine, all
I needed to do was write a function that inverted the y coordinate to get
the "real" value.

If your use of openGL changes anything about the mouse coordinates
returned from pygame, then I think it's a bug, like Alex says. Moving
the mouse down (towards you) should always make it's y position
increase, and moving it up (away from you) should always make it's y
position decrease.

However, when it comes to window coordinates, openGL by default uses a
coordinate system where 0,0 is the lower left, and positive x goes
right and positive y goes up. This is different from most computer
systems where y goes down and 0,0 is the upper left. OpenGL uses the
system it does because it follows the conventions of the cartesian
coordinate space used in math & physics. The place where you'd notice
this the most in games is when using trig functions like sin & cos,
which also are designed for math & physics & openGL coordinate systems
(positive rotations are counter-clockwise, 0 degrees is straight right
& y is up)

So basically, I'm saying it's not that the mouse is "flipped" with
OpenGL, it's that unless you set up your transforms to change it,
OpenGL is "flipped" from what all the pygame/SDL and desktop position
stuff is