We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4197

Summary: Screen width and height reported by SDL_GetCurrentDisplayMode changes after SDL_CreateWindow is called on iPad
Product: SDL Reporter: Steve Robinson <ssrobins>
Component: renderAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.8   
Hardware: iPhone/iPod touch   
OS: iOS 8   

Description Steve Robinson 2018-06-09 23:37:03 UTC
On my iPad simulator (Xcode 9.4) and iPad hardware, I noticed that SDL_GetCurrentDisplayMode(0, &current) reported these screen width and height values before SDL_CreateWindow is called:

current.w=320
current.h=480

And these after:

current.w=768
current.h=1024

These numbers did not change on iPhone simulator or hardware, nor did they change on Windows, Linux, Mac or Android.

I tracked the change down to UIKit_GetDisplayModes.  Here's the call stack:

SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
  SDL_FinishWindowCreation(window, flags);
    SDL_SetWindowFullscreen(window, flags); - w and h get zeroed out here
    SDL_ShowWindow(window);
      SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0);
        SDL_OnWindowShown(window);
          SDL_OnWindowRestored(window);
            SDL_UpdateFullscreenMode(window, SDL_TRUE);
              SDL_GetWindowDisplayMode(other, &fullscreen_mode)
                SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window),
                                             &fullscreen_mode,
                                             &fullscreen_mode)
                  SDL_GetNumDisplayModesForDisplay(display)
                     _this->GetDisplayModes(_this, display)
                       UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)

In my program, I simply made sure I only called SDL_GetCurrentDisplayMode once to get consistent behavior across all platforms.  Still, it was really confusing and I spent a lot of time messing with it so I figured I should log a bug.