diff --git a/ios/AppDelegate.h b/ios/AppDelegate.h index 263e85d369..feb65efbf4 100644 --- a/ios/AppDelegate.h +++ b/ios/AppDelegate.h @@ -7,6 +7,7 @@ @interface AppDelegate : UIResponder @property (strong, nonatomic) UIWindow *window; +@property (strong, nonatomic) UIScreen *screen; @property (strong, nonatomic) ViewController *viewController; diff --git a/ios/AppDelegate.mm b/ios/AppDelegate.mm index 5ae6e18003..34b90b2bbe 100644 --- a/ios/AppDelegate.mm +++ b/ios/AppDelegate.mm @@ -72,15 +72,27 @@ } -(BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; - self.viewController = [[ViewController alloc] init]; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]]; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMediaServicesWereReset:) name:AVAudioSessionMediaServicesWereResetNotification object:nil]; - - self.window.rootViewController = self.viewController; - [self.window makeKeyAndVisible]; + + [[NSNotificationCenter defaultCenter] addObserverForName:UIScreenDidConnectNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull notification) { + UIScreen* screen = (UIScreen*)notification.object; + self.screen = screen; + + NSLog(@"Display connected: %@", screen.debugDescription); + UIScreenMode* mode = screen.availableModes[screen.availableModes.count - 1]; + [screen setCurrentMode:mode]; + [screen setOverscanCompensation:UIScreenOverscanCompensationNone]; + + self.window = [[UIWindow alloc] initWithFrame:[screen bounds]]; + [self.window setScreen:screen]; + self.viewController = [[ViewController alloc] init]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioSessionInterruption:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]]; + + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMediaServicesWereReset:) name:AVAudioSessionMediaServicesWereResetNotification object:nil]; + + self.window.rootViewController = self.viewController; + [self.window makeKeyAndVisible]; + }]; return YES; } diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 5eba171e2b..8ebae24cdc 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -5,6 +5,7 @@ // Modified by xSacha // +#import "AppDelegate.h" #import "ViewController.h" #import "SubtleVolume.h" #import @@ -144,7 +145,8 @@ static GraphicsContext *graphicsContext; - (void)viewDidLoad { [super viewDidLoad]; - self.view.frame = [[UIScreen mainScreen] bounds]; + UIScreen* screen = [(AppDelegate*)[UIApplication sharedApplication].delegate screen]; + self.view.frame = [screen bounds]; self.view.multipleTouchEnabled = YES; self.context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; @@ -159,12 +161,13 @@ static GraphicsContext *graphicsContext; self.preferredFramesPerSecond = 60; // Might be useful for a speed boot, sacrificing resolution: - // view.contentScaleFactor = 1.0; + view.contentScaleFactor = screen.scale; - float scale = [UIScreen mainScreen].scale; + float scale = screen.scale; + - if ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)]) { - scale = [UIScreen mainScreen].nativeScale; + if ([screen respondsToSelector:@selector(nativeScale)]) { + scale = screen.nativeScale; } CGSize size = [[UIApplication sharedApplication].delegate window].frame.size; @@ -176,8 +179,8 @@ static GraphicsContext *graphicsContext; } g_dpi = (IS_IPAD() ? 200.0f : 150.0f) * scale; - g_dpi_scale_x = 240.0f / g_dpi; - g_dpi_scale_y = 240.0f / g_dpi; + g_dpi_scale_x = 1;//240.0f / g_dpi; + g_dpi_scale_y = 1;//240.0f / g_dpi; g_dpi_scale_real_x = g_dpi_scale_x; g_dpi_scale_real_y = g_dpi_scale_y; pixel_xres = size.width * scale;