diff --git a/src/platform/platform_macos/gryphn_platform_macos.h b/src/platform/platform_macos/gryphn_platform_macos.h index d448cb9..0ae8e18 100644 --- a/src/platform/platform_macos/gryphn_platform_macos.h +++ b/src/platform/platform_macos/gryphn_platform_macos.h @@ -12,9 +12,11 @@ typedef void CAMetalLayer; typedef void MTKView; #endif -MTKView* gnCreateMTKView(NSWindow* window); -void gnWindowSetMTKView(NSWindow* window, MTKView* view); +// MTKView* gnCreateMTKView(NSWindow* window); +// void gnWindowSetMTKView(NSWindow* window, MTKView* view); +CAMetalLayer* gnCreateCAMetalLayer(NSWindow* window); CAMetalLayer* gnGetCAMetalLayer(NSWindow* window); +void gnAttachMetalLayer(NSWindow* window, CAMetalLayer* layer); // CAMetalLayer* gnCreateMetalLayer(NSWindow* window); // void gnAttachMetalLayer(NSWindow* window, CAMetalLayer* layer); diff --git a/src/platform/platform_macos/gryphn_platform_macos.m b/src/platform/platform_macos/gryphn_platform_macos.m index 2e80f61..31324cf 100644 --- a/src/platform/platform_macos/gryphn_platform_macos.m +++ b/src/platform/platform_macos/gryphn_platform_macos.m @@ -48,11 +48,32 @@ void gnWindowSetMTKView(NSWindow* window, MTKView* view) { [window setContentView:view]; } -CAMetalLayer* gnGetCAMetalLayer(NSWindow* window) { - MTKView* view = window.contentView; - return (CAMetalLayer*)view.layer; +CAMetalLayer* gnCreateCAMetalLayer(NSWindow* window) { + CAMetalLayer* layer = [CAMetalLayer layer]; + layer.pixelFormat = MTLPixelFormatBGRA8Unorm; + layer.frame = window.contentView.layer.bounds; + window.contentView.wantsLayer = YES; + window.contentView.layer = layer; + return layer; } +CAMetalLayer* gnGetCAMetalLayer(NSWindow* window) { + return (CAMetalLayer*)window.contentView.layer; +} + +void gnAttachMetalLayer(NSWindow* window, CAMetalLayer* layer) { + // CGSize newSize = window.contentView.bounds.size; + // CGFloat scale = window.contentView.window.backingScaleFactor; + // layer.drawableSize = CGSizeMake(newSize.width * scale, newSize.height * scale); + // CAMetalLayer* layer = [CAMetalLayer layer]; + // layer.pixelFormat = MTLPixelFormatBGRA8Unorm; + // layer.frame = window.contentView.layer.bounds; + // window.contentView.wantsLayer = YES; + // window.contentView.layer = layer; + layer.drawableSize = CGSizeMake(window.frame.size.width, window.frame.size.height); +} + + /* CAMetalLayer* gnCreateMetalLayer(NSWindow* window) { // CAMetalLayer* layer = [CAMetalLayer layer];