Merge pull request #923 from stuartcarnie/master

Support MetalKit view as an option on all Apple platforms
This commit is contained in:
Branimir Karadžić 2016-09-18 18:19:59 -07:00 committed by GitHub
commit c98779640f
3 changed files with 10 additions and 0 deletions

View File

@ -98,6 +98,7 @@ function bgfxProject(_name, _kind, _defines)
"-framework QuartzCore",
"-framework OpenGL",
"-weak_framework Metal",
"-weak_framework MetalKit",
}
configuration { "not nacl", "not linux-steamlink" }

View File

@ -12,6 +12,7 @@
#import <QuartzCore/CAMetalLayer.h>
#import <Metal/Metal.h>
#import <MetalKit/MetalKit.h>
#if BX_PLATFORM_IOS
# import <UIKit/UIKit.h>

View File

@ -378,8 +378,16 @@ namespace bgfx { namespace mtl
memset(m_uniforms, 0, sizeof(m_uniforms) );
memset(&m_resolution, 0, sizeof(m_resolution) );
if (NULL != NSClassFromString(@"MTKView")) {
MTKView *view = (MTKView *)g_platformData.nwh;
if (NULL != view && [view isKindOfClass:NSClassFromString(@"MTKView")]) {
m_metalLayer = (CAMetalLayer *)view.layer;
}
}
if (NULL != NSClassFromString(@"CAMetalLayer") )
{
if (NULL == m_metalLayer)
#if BX_PLATFORM_IOS
{
CAMetalLayer* metalLayer = (CAMetalLayer*)g_platformData.nwh;