Mac: Make metal layer inherit content sale from window to fix issues swapping between retina and non-retina monitors

This commit is contained in:
Michael Buckley 2020-03-01 16:59:00 -08:00
parent 0a8972524d
commit 0a9d83654b
1 changed files with 13 additions and 0 deletions

View File

@ -55,7 +55,18 @@ typedef struct
vector_float2 textureCoordinate;
} MetalVertex;
@interface MetalLayerDelegate: NSObject<CALayerDelegate, NSViewLayerContentScaleDelegate>
@end
@implementation MetalLayerDelegate
- (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window
{
return YES;
}
@end
CAMetalLayer *metalLayer = nil;
MetalLayerDelegate *layerDelegate = nil;
id<MTLDevice> metalDevice = nil;
id<MTLTexture> metalTexture = nil;
id<MTLCommandQueue> metalCommandQueue = nil;
@ -147,6 +158,8 @@ static void S9xInitMetal (void)
glScreenH = glScreenBounds.size.height;
metalLayer = (CAMetalLayer *)s9xView.layer;
layerDelegate = [MetalLayerDelegate new];
metalLayer.delegate = layerDelegate;
metalDevice = s9xView.device;