Go to file
Sam Lantinga 9dbe5a9686 Fixed bug 3311 - Broken touch positions with SDL_RenderSetLogicalSize & HIGHDPI on iOS
Eric wing

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".
2017-08-02 13:38:46 -07:00
VisualC Updated Visual Studio 2008 project 2017-07-10 15:55:13 -07:00
VisualC-WinRT WinRT: removed Windows 8.0 from build-bot + NuGet package creation scripts 2017-02-25 21:23:12 -05:00
Xcode Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Xcode-iOS ios: Fixed math include in demos. 2017-05-25 23:01:59 +02:00
acinclude Fixed bug 3481 - Configure fails to detect dynamic library support on powerpc64le 2016-11-06 20:26:48 -08:00
android-project android: add screenSize to AndroidManifest's configChanges (thanks, Daniel!). 2017-05-19 15:06:05 -04:00
build-scripts Disable static builds for static analysis. 2017-07-30 14:36:01 -04:00
cmake Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
debian We don't actually build with the Xt library 2017-01-10 23:23:32 -08:00
docs raspberrypi: Fixed typos in README. 2017-06-24 23:45:34 +02:00
include Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
src Fixed bug 3311 - Broken touch positions with SDL_RenderSetLogicalSize & HIGHDPI on iOS 2017-08-02 13:38:46 -07:00
test Fixed typo in log message in testime program. 2017-07-09 23:00:35 +02:00
visualtest Updated copyright for 2017 2017-01-01 18:33:28 -08:00
.hgignore wayland: Build own version of core protocol 2016-06-23 18:39:05 +08:00
Android.mk Make sure the memory barrier functions are always available, and now they are implemented on Android __ARM_ARCH_5TE__ 2017-02-10 11:21:15 -08:00
BUGS.txt BUGS.txt: Changed mailing list link to discourse.libsdl.org. 2017-04-01 00:05:25 -04:00
CMakeLists.txt Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
COPYING.txt Updated copyright for 2017 2017-01-01 18:33:28 -08:00
CREDITS.txt Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00
INSTALL.txt More HTTPS doc tweaks. 2017-02-16 16:59:07 -05:00
Makefile.in wayland: Build own version of core protocol 2016-06-23 18:39:05 +08:00
Makefile.minimal Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00
Makefile.pandora pandora: Fixed compiler warning about redefining SDL_REVISION. 2017-06-18 23:00:27 +02:00
Makefile.psp PSP: Added missing object for generic TLS to Makefile. 2016-02-13 17:34:14 +01:00
Makefile.wiz Pandora: Updated SDL version in Makefile. 2016-07-19 21:01:30 +02:00
README-SDL.txt More HTTPS changes in the documentation. 2017-02-16 16:52:03 -05:00
README.txt readme: correct webpage URL to use HTTPS. 2017-02-16 13:30:34 -05:00
SDL2.spec.in Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00
TODO.txt Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00
VisualC.html Fixed two typos in documentation. 2016-01-12 22:23:53 +01:00
WhatsNew.txt Added note for David Carlier's work on OpenBSD 2016-10-12 18:57:12 -07:00
autogen.sh Don't use pushd/popd in autogen.sh; Ubuntu's /bin/sh doesn't support it. 2016-12-26 22:58:58 -05:00
cmake_uninstall.cmake.in Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00
configure Fixed bug 3609 - Windows build fails due to conflicting types for 'XINPUT_GAMEPAD_EX' 2017-07-10 18:31:28 -07:00
configure.in Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
sdl2-config.cmake.in Applied Ubuntu patch bug_822210_fix_sdl2-config.cmake_whitespace.patch 2016-10-07 15:08:37 -07:00
sdl2-config.in Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00
sdl2.m4 Fixed bug 3429 - Update AM_PATH_SDL2() to also check for SDL2.framework 2016-09-29 16:37:08 -07:00
sdl2.pc.in Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00

README.txt

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.


                         Simple DirectMedia Layer

                                  (SDL)

                                Version 2.0

---
https://www.libsdl.org/

Simple DirectMedia Layer is a cross-platform development library designed
to provide low level access to audio, keyboard, mouse, joystick, and graphics
hardware via OpenGL and Direct3D. It is used by video playback software,
emulators, and popular games including Valve's award winning catalog
and many Humble Bundle games.

More extensive documentation is available in the docs directory, starting
with README.md

Enjoy!
	Sam Lantinga				(slouken@libsdl.org)