Hi, I think I may have found a bug with the mouse
coordinates with SDL in OS X. It looks like this bug
has been reported before but it doesn’t look like the
problem has been resolved yet. It looks like it was
reported back in December under the thread “Inverted
y-coords in OS-X” and that thread makes mention to an
earlier report. But here is a more detailed report of
When running SDL in OpenGL mode in a windowed mode
(not fullscreen), the y-mouse coordinates seem to be
inverted from SDL convention meaning the bottom-left
corner of the window is (0,0) instead of the top-left.
Strangely, this only happens in Windowed OpenGL mode.
In fullscreen OpenGL, fullscreen SDL2D, and windowed
SDL2D modes, the coordinates are consistent with SDL
I was able to easily demonstrate the problem by using
the sample test program created by the Xcode
stationary posted here a few months ago. I started
wiith a normal SDL application and added print
statements. I added code to test both windowed and
fullscreen. I then changed the code to initialize
OpenGL as the video mode and retested windowed and
fullscreen modes. Only the OpenGL-windowed mode
demonstrated the problems. I also repeated the tests
with “testgl” and “testbitmap” that come with SDL. My
results were consistent there as well.
From the previous message threads, it seems to be well
known that Quartz follows the convention with the
bottom-left coordinate at (0,0), but it seems to be
acting inconsistently between the windowed 2D and 3D
modes. Looking at the source, for the windowed code,
it seems to follow all one path so I don’t know why it
would be flipped in one case. I don’t know the Apple
API’s (Cocoa, CoreGraphics, etc), but I might
speculate that maybe mixing NS and CG calls might have
accidentally led to the inconsistency, but that’s pure
speculation and I might be just as inclined to call it
an Apple bug. Somebody more knowledgeable with Cocoa
might want to investigate this further.
For the meantime, attached is a workaround patch that
should reinvert the coordinates for this one case.
This fixed all my simple cases and my own programs,
but somebody might want to check to see if this fix
needs to be applied in other places of the source code
for SDL functions I didn’t test.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…