From ac2d1f677371bfcc1e88de462d57db038828f70d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 2 Mar 2018 12:08:18 -0800 Subject: [PATCH] Fixed setting the layer drawable size Without this change the drawable had a size of 0 and the metal renderer asserted because the projection matrix wasn't set. --- src/video/uikit/SDL_uikitmetalview.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/video/uikit/SDL_uikitmetalview.m b/src/video/uikit/SDL_uikitmetalview.m index 104189d8c..63adf7cd8 100644 --- a/src/video/uikit/SDL_uikitmetalview.m +++ b/src/video/uikit/SDL_uikitmetalview.m @@ -60,7 +60,14 @@ /* Set the size of the metal drawables when the view is resized. */ - (void)layoutSubviews { + CGSize bounds; + [super layoutSubviews]; + + bounds = [self bounds].size; + bounds.width *= self.layer.contentsScale; + bounds.height *= self.layer.contentsScale; + ((CAMetalLayer *) self.layer).drawableSize = bounds; } @end @@ -72,9 +79,9 @@ UIKit_Mtl_AddMetalView(SDL_Window* window) SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view; CGFloat scale = 1.0; - if ([view isKindOfClass:[SDL_uikitmetalview class]]) { - return (SDL_uikitmetalview *)view; - } + if ([view isKindOfClass:[SDL_uikitmetalview class]]) { + return (SDL_uikitmetalview *)view; + } if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { /* Set the scale to the natural scale factor of the screen - then