Fix vulkan view resizing on iOS

This commit is contained in:
2023-09-17 14:32:22 +02:00
parent 793c35e274
commit de75b6c724

View File

@@ -41,7 +41,7 @@ public:
void SetWindowMode(WindowMode) override {}
const WindowConfiguration & GetWindowConfiguration() override { return windowConf; }
void SetSize(uint32_t width, uint32_t height) override {}
void SetSize(uint32_t width, uint32_t height) override { windowConf.size = { width, height }; }
void SetSizeLimits(int minWidth, int minHeight, int maxWidth, int maxHeight) override {}
Math::Vector2i GetPosition() override { return { 0,0 }; }
@@ -95,16 +95,20 @@ public:
@implementation MetalViewDelegate
{
GraphicsAppManager* manager;
IWindow* window;
}
- (id)initWithGAM:(GraphicsAppManager*)gam
- (id)initWithGAM:(GraphicsAppManager*)gam win:(IWindow*)win
{
manager = gam;
window = win;
return self;
}
- (void) mtkView:(MTKView *) view drawableSizeWillChange:(CGSize) size
{}
{
manager->OnWindowResize(window, size.width, size.height);
}
- (void) drawInMTKView:(MTKView *) view
{
@@ -136,7 +140,7 @@ public:
-(void) viewDidLoad {
[super viewDidLoad];
self.view.contentScaleFactor = UIScreen.mainScreen.nativeScale;
self.view.contentScaleFactor = UIScreen.mainScreen.nativeScale / 1.5f;
auto size = self.view.bounds.size;
auto sizeX = size.width * self.view.contentScaleFactor;
@@ -150,7 +154,7 @@ public:
manager->StartUp();
OpenVulkanoView* mtkView = (OpenVulkanoView*)(self.view);
mtdelegate = [[MetalViewDelegate alloc] initWithGAM:manager];
mtdelegate = [[MetalViewDelegate alloc] initWithGAM:manager win:&window];
[mtkView setDelegate:mtdelegate];
mtkView.preferredFramesPerSecond = 60;
}