macos helpers
This commit is contained in:
@@ -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);
|
||||
|
@@ -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];
|
||||
|
Reference in New Issue
Block a user