Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
https://bugzilla.libsdl.org/show_bug.cgi?id=4577
SDL_GetWindowDisplayMode was returning an incorrect result on iPhone Plus devices (tested on iOS 12.1/12.2).  The problem was that the value returned by UIScreenMode was assumed to be the physical pixels on the display, rather than the scaled retina pixels.  The fix is to use the scale returned by UIScreen.scale rather than the nativeScale.
  • Loading branch information
slouken committed Apr 5, 2019
1 parent 05333a6 commit b6f33a6
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/video/uikit/SDL_uikitmodes.m
Expand Up @@ -216,17 +216,18 @@ @implementation SDL_DisplayModeData
availableModes = data.uiscreen.availableModes;
#endif

#ifdef __IPHONE_8_0
/* The UIScreenMode of an iPhone 6 Plus should be 1080x1920 rather than
* 1242x2208 (414x736@3x), so we should use the native scale. */
if ([data.uiscreen respondsToSelector:@selector(nativeScale)]) {
scale = data.uiscreen.nativeScale;
}
#endif

for (UIScreenMode *uimode in availableModes) {
/* The size of a UIScreenMode is in pixels, but we deal exclusively
* in points (except in SDL_GL_GetDrawableSize.) */
* in points (except in SDL_GL_GetDrawableSize.)
*
* For devices such as iPhone 6/7/8 Plus, the UIScreenMode reported
* by iOS is not in physical pixels of the display, but rather the
* point size times the scale. For example, on iOS 12.2 on iPhone 8
* Plus the uimode.size is 1242x2208 and the uiscreen.scale is 3
* thus this will give the size in points which is 414x736. The code
* used to use the nativeScale, assuming UIScreenMode returned raw
* physical pixels (as suggested by its documentation, but in
* practice it is returning the retina pixels). */
int w = (int)(uimode.size.width / scale);
int h = (int)(uimode.size.height / scale);

Expand Down

0 comments on commit b6f33a6

Please sign in to comment.