diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-01-07 21:18:25 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-14 11:50:18 +0100 |
commit | 0fc763bc5597e04ee528a34ca2730f780d25fb5e (patch) | |
tree | 5423154a86243834a24b17bbe1072d022acbf786 /src/video/cocoa/cocoa_v.mm | |
parent | 8906e9e0fd6dc7bd64f9ad2c633da6f110dbf921 (diff) | |
download | openttd-0fc763bc5597e04ee528a34ca2730f780d25fb5e.tar.xz |
Change: [OSX] Render screen in full native resolution on HiDPI displays.
Diffstat (limited to 'src/video/cocoa/cocoa_v.mm')
-rw-r--r-- | src/video/cocoa/cocoa_v.mm | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index c1fb996de..c21edc7ac 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -322,6 +322,11 @@ void VideoDriver_Cocoa::GameSizeChanged() BlitterFactory::GetCurrentBlitter()->PostResize(); ::GameSizeChanged(); + + /* We need to store the window size as non-Retina size in + * the config file to get same windows size on next start. */ + _cur_resolution.width = [ this->cocoaview frame ].size.width; + _cur_resolution.height = [ this->cocoaview frame ].size.height; } /** @@ -491,7 +496,7 @@ void VideoDriver_Cocoa::Draw(bool force_update) /* Normally drawRect will be automatically called by Mac OS X during next update cycle, * and then blitting will occur. If force_update is true, it will be done right now. */ - [ this->cocoaview setNeedsDisplayInRect:dirtyrect ]; + [ this->cocoaview setNeedsDisplayInRect:[ this->cocoaview getVirtualRect:dirtyrect ] ]; if (force_update) [ this->cocoaview displayIfNeeded ]; } @@ -530,7 +535,7 @@ void VideoDriver_Cocoa::AllocateBackingStore() { if (this->window == nil || this->cocoaview == nil || this->setup) return; - NSRect newframe = [ this->cocoaview frame ]; + NSRect newframe = [ this->cocoaview getRealRect:[ this->cocoaview frame ] ]; this->window_width = (int)newframe.size.width; this->window_height = (int)newframe.size.height; @@ -743,6 +748,13 @@ void VideoDriver_Cocoa::GameLoop() CGImageRelease(fullImage); } +- (void)viewDidChangeBackingProperties +{ + [ super viewDidChangeBackingProperties ]; + + self.layer.contentsScale = [ driver->cocoaview getContentsScale ]; +} + @end #endif /* WITH_COCOA */ |