Broken touch positions with SDL_RenderSetLogicalSize & HIGHDPI on iOS

Hi, I think I found a bug when using SDL_WINDOW_ALLOW_HIGHDPI with
SDL_RenderSetLogicalSize on iOS. I use SDL_RenderSetLogicalSize for
all my stuff. I just tried turning on SDL_WINDOW_ALLOW_HIGHDPI on iOS
and suddenly all my touch/mouse positions are really
broken/far-off-the-mark.

I actually don’t have a real retina device (still) so I’m seeing this
using the iOS simulator with a 6plus template.

Attached is a simple test program that can reproduce the problem. It
uses RenderSetLogicalSize and draws some moving happy faces (to show
the boundaries/space of the LogicalSize and that it is working
correctly for that part).

When you click/touch, it will draw one more happy face where your
button point is.

If you comment out SDL_WINDOW_ALLOW_HIGHDPI, everything works as
expected. But if you compile with it in, the mouse coordinates seem
really far off the mark. (Face appears far up and to the left.)

I’m wondering if anybody has encountered this, knows more about it
(maybe it is caused by something else), or knows how to fix it.

Thanks,
Eric
-------------- next part --------------
A non-text attachment was scrubbed…
Name: main_c.c
Type: text/x-csrc
Size: 10948 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20160420/2c3ea254/attachment-0001.c

I believe this is a bug in SDL_Render?s platform-agnostic mouse coordinate scaling code. It assumes the units of the mouse coordinates are always in pixels, which isn?t the case where high-DPI is involved (regardless of whether iOS is used) ? they?re actually in ?DPI independent? coordinates (which matches the window size, but not the renderer output size).> On Apr 20, 2016, at 6:08 PM, Eric Wing wrote:

Hi, I think I found a bug when using SDL_WINDOW_ALLOW_HIGHDPI with
SDL_RenderSetLogicalSize on iOS. I use SDL_RenderSetLogicalSize for
all my stuff. I just tried turning on SDL_WINDOW_ALLOW_HIGHDPI on iOS
and suddenly all my touch/mouse positions are really
broken/far-off-the-mark.

I actually don’t have a real retina device (still) so I’m seeing this
using the iOS simulator with a 6plus template.

Attached is a simple test program that can reproduce the problem. It
uses RenderSetLogicalSize and draws some moving happy faces (to show
the boundaries/space of the LogicalSize and that it is working
correctly for that part).

When you click/touch, it will draw one more happy face where your
button point is.

If you comment out SDL_WINDOW_ALLOW_HIGHDPI, everything works as
expected. But if you compile with it in, the mouse coordinates seem
really far off the mark. (Face appears far up and to the left.)

I’m wondering if anybody has encountered this, knows more about it
(maybe it is caused by something else), or knows how to fix it.

Thanks,
Eric
<main_c.c>_______________________________________________
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Do you know if Mac is affected by this problem too? (I don’t have a
retina Mac either.)

Thanks,
EricOn 4/20/16, Alex Szpakowski wrote:

I believe this is a bug in SDL_Render?s platform-agnostic mouse coordinate
scaling code. It assumes the units of the mouse coordinates are always in
pixels, which isn?t the case where high-DPI is involved (regardless of
whether iOS is used) ? they?re actually in ?DPI independent? coordinates
(which matches the window size, but not the renderer output size).

If my hypothesis is correct, then yes (as well as any other platform SDL adds high-dpi support for in the future).> On Apr 20, 2016, at 9:37 PM, Eric Wing wrote:

Do you know if Mac is affected by this problem too? (I don’t have a
retina Mac either.)

Thanks,
Eric


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

If my hypothesis is correct, then yes (as well as any other platform SDL
adds high-dpi support for in the future).

Do you know if Mac is affected by this problem too? (I don’t have a
retina Mac either.)

Okay, I just filed a bug so this isn’t lost.
https://bugzilla.libsdl.org/show_bug.cgi?id=3311

Thanks,
EricOn 4/20/16, Alex Szpakowski wrote:

On Apr 20, 2016, at 9:37 PM, Eric Wing <@Eric_Wing> wrote: