Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL_GetDisplayMode() on iPad gives 1024x768 instead of 768x1024 #360

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

SDL_GetDisplayMode() on iPad gives 1024x768 instead of 768x1024 #360

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Labels
invalid This doesn't seem right

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.0
Reported for operating system, platform: iOS (All), iPhone/iPod touch

Comments on the original bug report:

On 2011-02-17 07:43:51 +0000, Kees Bakker wrote:

The Apple doc says: "All iOS applications launch in portrait mode initially...".

So, the expectation is that the main screen dimension should be: width 768, height 1024.

However, it is reversed (as if the screen is in landscape).

For some reason this returns the correct numbers.

[uiscreen bounds]

But, depending on the value of SDL_UIKit_supports_multiple_displays, we do the following and then the numbers are in the reversed order.

[[uiscreen currentMode] size]

Also notice that the developer doc says that bounds gives numbers in "points", and "size" gives the numbers in "pixels". Wow Apple, that is helpful.

Please also notice that calling SDL_CreateWindow with width 1024 and height 768 (i.e. landscape mode) will return an SDL_Window object where width and height are magically reversed to match the portrait mode.

On 2011-02-17 07:46:15 +0000, Kees Bakker wrote:

There is a workaround and that it to leave SDL_UIKit_supports_multiple_displays set to "NO".

In that case the code will pick the [uiscreen bounds] version.

diff -r 48067bfc300c src/video/uikit/SDL_uikitvideo.m
--- a/src/video/uikit/SDL_uikitvideo.m Mon Feb 14 11:50:18 2011 -0600
+++ b/src/video/uikit/SDL_uikitvideo.m Wed Feb 16 23:58:23 2011 +0100
@@ -184,8 +184,10 @@

 NSString *reqSysVer = @"3.2";
 NSString *currSysVer = [[UIDevice currentDevice] systemVersion];

+#if 0
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending)
SDL_UIKit_supports_multiple_displays = YES;
+#endif

 // If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels.
 //  The iPad added both a larger main screen and the ability to use

On 2011-03-25 13:18:05 +0000, Sam Lantinga wrote:

Ryan volunteered to look at this bug.

On 2011-03-26 22:31:46 +0000, Ryan C. Gordon wrote:

(In reply to comment # 0)

The Apple doc says: "All iOS applications launch in portrait mode
initially...".

This isn't actually true; I think that's a default, but you can specify the initial orientation in your app's Info.plist.

So, the expectation is that the main screen dimension should be: width 768,
height 1024.

I'm patching this to report both heights as available screen sizes, and orienting the screen based on what the user requests (and listening for orientation events and reporting a window resize event, if the app requested the window be "resizable").

Also notice that the developer doc says that bounds gives numbers in "points",
and "size" gives the numbers in "pixels". Wow Apple, that is helpful.

I'm pretty sure they specified that, for the pre-3.2 devices, "points" always equals pixels. For iOS devices updated to 3.2 or later, they use the "size" codepath which reports pixels...so it all works out in this case.

Please also notice that calling SDL_CreateWindow with width 1024 and height 768
(i.e. landscape mode) will return an SDL_Window object where width and height
are magically reversed to match the portrait mode.

This is being fixed; it'll force the orientation to match your window request, so if you want 1024x768, it'll render in landscape.

--ryan.

On 2011-10-10 11:30:10 +0000, Kees Bakker wrote:

I have a better fix for this problem (as mentioned on the SDL mailing list). My fix is available at bitbucket. See https://bitbucket.org/keestux/sdl

On 2013-05-21 02:21:56 +0000, Sam Lantinga wrote:

Both modes are listed, but SDL sorts landscape modes first. If you look at the current mode it will correctly show 768x1024 based on the device orientation.

@SDLBugzilla SDLBugzilla added bug invalid This doesn't seem right labels Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

1 participant