# Broken touch positions with SDL\_RenderSetLogica lSize & HIGHDPI on iOS

**URL:** <https://discourse.libsdl.org/t/broken-touch-positions-with-sdl-rendersetlogica-lsize-highdpi-on-ios/21764>\
**Category:** SDL Development\
**Created:** [April 21, 2016, 8:50am UTC](https://discourse.libsdl.org/t/broken-touch-positions-with-sdl-rendersetlogica-lsize-highdpi-on-ios/21764 "2016-04-21T08:50:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hardcoredaniel](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/9de053/32.png) [@hardcoredaniel](https://discourse.libsdl.org/u/hardcoredaniel)\
**Post date:** [April 21, 2016, 8:50am UTC](https://discourse.libsdl.org/t/broken-touch-positions-with-sdl-rendersetlogica-lsize-highdpi-on-ios/21764/1 "2016-04-21T08:50:58Z")

</div>

I can confirm the “problem”, too, on iOS, but I always assumed that it is  
intentional. From my memory (probably not correct terms I’m using) I  
understood that the SDL window is in points, and so will be all touch and  
mouse coordinates. If you specify HIGHDPI, then you need to query the  
renderer for the pixel resolution to check whether there’s a mismatch to the  
“points”. It was unexpected for me to handle touch events in a different  
coordinate system than to handle rendering, but it looks like SDL is  
consistent in that separation (at least at the moment).

---------- P?vodn? zpr?va ----------  
Od: Eric Wing   
Komu: SDL Development List   
Datum: 21. 4. 2016 2:50:59  
P?edm?t: Re: [SDL] Broken touch positions with SDL\_RenderSetLogicalSize &  
HIGHDPI on iOS

"On 4/20/16, Alex Szpakowski wrote:

> 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://github.com/libsdl-org/SDL/issues/2144>
>
> \# This bug report was migrated from our old Bugzilla tracker.
> 
> These attachments… are available in the static archive:
> 
> \* \[Sample SDL program reproducing SDL\_RenderSetLogicalSize & SDL\_WINDOW\_ALLOW\_HIGHDPI bug (main\_c.c, text/plain, 2016-04-21 00:49:42 +0000, 10949 bytes)\](https://bugzilla.libsdl.org/attachment.cgi?id=2434)
> 
> \*\*Reported in version:\*\* 2.0.4
> \*\*Reported for operating system, platform:\*\* iOS (All), All
> 
> \# Comments on the original bug report:
> 
> On 2016-04-21 00:49:42 +0000, Eric wing wrote:
> 
> \> Created attachment 2434
> \> Sample SDL program reproducing SDL\_RenderSetLogicalSize & SDL\_WINDOW\_ALLOW\_HIGHDPI bug
> \> 
> \> 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.)
> \> 
> \> 
> \> Alex Szpakowski on the mailing list suggests the problem is
> \> "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)."
> \> 
> \> Additionally, if this is correct, the Mac under Retina is also probably affected too and "as well as any other platform SDL adds high-dpi support for in the future".
> 
> On 2016-09-06 07:03:06 +0000, Jeremiah Morris wrote:
> 
> \> I ran into this today on a Retina Mac. Running 2.0.4, haven't checked Mercurial yet. Mouse coordinates were roughly half what they should have been; X was more off due to the difference between my logical aspect ratio and the monitor's aspect. Without the HIGHDPI flag, everything works great.
> 
> On 2017-08-02 20:39:09 +0000, Sam Lantinga wrote:
> 
> \> Fixed, thanks!
> \> https://hg.libsdl.org/SDL/rev/0ef6b8b9ca6d

Thanks,  
Eric\>\> On Apr 20, 2016, at 9:37 PM, Eric Wing wrote:

* * *

SDL mailing list  
SDL at [lists.libsdl.org](http://lists.libsdl.org)  
[http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)"
