From c5dcb0009cc96330674fb4b55d820e79fe42e034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 22 Oct 2025 15:19:12 +0200 Subject: [PATCH] Support screen rotation in OpenGL as well. --- ios/ViewController.mm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 62e776e21c..57e04de1ab 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -643,6 +643,23 @@ void GLRenderLoop(IOSGLESContext *graphicsContext) { [self hideKeyboard]; } +- (void)viewWillTransitionToSize:(CGSize)size + withTransitionCoordinator:(id)coordinator { + [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; + + [self.view endEditing:YES]; // clears any input focus + + [coordinator animateAlongsideTransition:^(id context) { + NSLog(@"Rotating to size: %@", NSStringFromCGSize(size)); + } completion:^(id context) { + NSLog(@"Rotation finished"); + // Reinitialize graphics context to match new size + [self requestExitGLRenderLoop]; + [self runGLRenderLoop]; + [[DisplayManager shared] updateResolution:[UIScreen mainScreen]]; + }]; +} + @end void bindDefaultFBO()