Metal: Add support of setting CAMetalLayer as PlatformData.nwh for macOS(OSX) platform (#1218)

This commit is contained in:
tommyZZM 2017-08-06 01:44:27 +08:00 committed by Branimir Karadžić
parent 2d126ea41d
commit c8012427d9
1 changed files with 10 additions and 4 deletions

View File

@ -401,10 +401,16 @@ namespace bgfx { namespace mtl
}
#elif BX_PLATFORM_OSX
{
NSWindow* nsWindow = (NSWindow*)g_platformData.nwh;
[nsWindow.contentView setWantsLayer:YES];
m_metalLayer = [CAMetalLayer layer];
[nsWindow.contentView setLayer:m_metalLayer];
NSObject* nvh = (NSObject*)g_platformData.nwh;
if ([nvh isKindOfClass:[CAMetalLayer class]]) {
CAMetalLayer* metalLayer = (CAMetalLayer*)g_platformData.nwh;
m_metalLayer = metalLayer;
} else {
NSWindow* nsWindow = (NSWindow*)g_platformData.nwh;
[nsWindow.contentView setWantsLayer:YES];
m_metalLayer = [CAMetalLayer layer];
[nsWindow.contentView setLayer:m_metalLayer];
}
}
#endif // BX_PLATFORM_*