Inverted y-coords in OS-X

The subject kind says it all : SDL is feeding me y coordinates which
increase from zero at the bottom of the screen, when running in a
window on OS-X. I know Cocoa is ‘inverted’ compared to Quickdraw / GDI
/ X11, but I’d assumed this is the sort of thing SDL would abstract
out?

I have verified the program behaves fine on Linux, and also that it’s
the actual numbers from the SDL events that are flipped

I searched for similar issues and found one message to this list by
Brian Hook, describing what sounds like the same problem : but that was
the middle of last year. I know lots of people are using SDL on OS-X,
so why is it only me seeing this problem?

OS-X is Panther 10.3.1
SDL is 1.2.6, compiled as a framework

Hoping for enlightenment…
James

PS - I have another odd OS-X issue no matter what I do, SDL won’t send
me SDL_VIDEORESIZE events (and the window Surface is indeed being
created resizable). I can cheerfully resize the window using the mouse,
but the SDL app never gets told about it. Again all is fine on Linux.–
There is no such thing as a humble opinion.
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: text/enriched
Size: 1112 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20031201/33d8a961/attachment.bin

I use the same setup (OSX 10.3.1 and SDL 1.2.6) and am getting fine
coordinates (offset from the top of the screen). Are you noticing this
in fullscreen or windowed? Does SDL_GetMouseState() return bad coords
as well, or just an event? What event types have this problem?
SDL_MOUSEMOTION, SDL_MOUSEBUTTONDOWN/UP?On Dec 2, 2003, at 2:52 AM, James Turner wrote:

The subject kind says it all : SDL is feeding me y coordinates which
increase from zero at the bottom of the screen, when running in a
window on OS-X. I know Cocoa is ‘inverted’ compared to Quickdraw / GDI
/ X11, but I’d assumed this is the sort of thing SDL would abstract
out?

I have verified the program behaves fine on Linux, and also that it’s
the actual numbers from the SDL events that are flipped

I searched for similar issues and found one message to this list by
Brian Hook, describing what sounds like the same problem : but that
was the middle of last year. I know lots of people are using SDL on
OS-X, so why is it only me seeing this problem?

OS-X is Panther 10.3.1
SDL is 1.2.6, compiled as a framework

I use the same setup (OSX 10.3.1 and SDL 1.2.6) and am getting fine
coordinates (offset from the top of the screen). Are you noticing this
in fullscreen or windowed? Does SDL_GetMouseState() return bad coords
as well, or just an event? What event types have this problem?
SDL_MOUSEMOTION, SDL_MOUSEBUTTONDOWN/UP?

This is in windowed mode, I can’t test fullscreen because when I switch
to that mode, the app fails to display anything (at a guess, it’s a new
GL context, so I need to reload all textures? Since the display doesn’t
redraw when I switch back to windowed mode either…).

Both the values from SDL_GetMouseState and the SDL_MOUSEMOTION,
MOUSEBUTTONUP and MOUSEBUTTONDOWN events are inverted (at least it’s
consistent).

I guess I’ll need to start looking through the code - does anyone know
where the Cocoa -> ‘normal’ Y-direction flip is supposed to be taking
place?

H&H
JamesOn 3 Dec 2003, at 02:36, John Philip wrote:

All hail the hypno-toad!

I use the same setup (OSX 10.3.1 and SDL 1.2.6) and am getting fine
coordinates (offset from the top of the screen). Are you noticing this
in fullscreen or windowed? Does SDL_GetMouseState() return bad coords
as well, or just an event? What event types have this problem?
SDL_MOUSEMOTION, SDL_MOUSEBUTTONDOWN/UP?

This is in windowed mode, I can’t test fullscreen because when I switch
to that mode, the app fails to display anything (at a guess, it’s a new
GL context, so I need to reload all textures?

Yes. The GL context is destroyed every time SDL_SetVideoMode() is
called, and all the gl state is destroyed with it (this includes
textures, among other things).

Since the display doesn’t
redraw when I switch back to windowed mode either…).

Just reload your textures, restore your viewport and projection matrix
etc, and it should work.

Both the values from SDL_GetMouseState and the SDL_MOUSEMOTION,
MOUSEBUTTONUP and MOUSEBUTTONDOWN events are inverted (at least it’s
consistent).

I can verify that this is happening. The Y coordinates get thrown off
whenever the mouse leaves the SDL portion of the window. I’m not sure
what the cause is, but the mouse focus detection is broken as well
which could be a factor. Since I wrote this code, I’ll try to fix it
when I get some free time. If you don’t want to wait, feel free; the
code is in src/video/quartz.On Dec 3, 2003, at 3:06 PM, sdl-request at libsdl.org wrote

On 3 Dec 2003, at 02:36, John Philip wrote:

I can conform this.

Cocoa natively reports the mouse coordinates relative to the lower left
corner (more similar to how the world outside of computer graphics does
coordinates, if that’s good or bad is well outside of the scope of
this…).

Anyhow, when moving the mouse up in a windowed GL context, a
SDL_MOUSEMOTION event as returned from SDL_PollEvent() gives positive
relative movement (inline with Cocoa’s native coords).

When switching to a grabbed mouse, SDL_WM_GrabInput(SDL_GRAB_ON),
upward movement is then reported as a negative delta, as if the origin
were at the top.

Both of these cases were in a windowed context.On Dec 3, 2003, at 2:26 AM, James Turner wrote:

On 3 Dec 2003, at 02:36, John Philip wrote:

I use the same setup (OSX 10.3.1 and SDL 1.2.6) and am getting fine
coordinates (offset from the top of the screen). Are you noticing
this in fullscreen or windowed? Does SDL_GetMouseState() return bad
coords as well, or just an event? What event types have this problem?
SDL_MOUSEMOTION, SDL_MOUSEBUTTONDOWN/UP?

This is in windowed mode, I can’t test fullscreen because when I
switch to that mode, the app fails to display anything (at a guess,
it’s a new GL context, so I need to reload all textures? Since the
display doesn’t redraw when I switch back to windowed mode either…).

Both the values from SDL_GetMouseState and the SDL_MOUSEMOTION,
MOUSEBUTTONUP and MOUSEBUTTONDOWN events are inverted (at least it’s
consistent).

I guess I’ll need to start looking through the code - does anyone know
where the Cocoa -> ‘normal’ Y-direction flip is supposed to be taking
place?

H&H
James

All hail the hypno-toad!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl