|
@@ -67,9 +67,21 @@ namespace bgfx { namespace gl
|
|
|
BX_CHECK(NULL != s_opengl, "OpenGL dynamic library is not found!");
|
|
BX_CHECK(NULL != s_opengl, "OpenGL dynamic library is not found!");
|
|
|
|
|
|
|
|
const AutoreleasePoolHolder pool;
|
|
const AutoreleasePoolHolder pool;
|
|
|
- NSWindow* nsWindow = (NSWindow*)g_platformData.nwh;
|
|
|
|
|
|
|
+ NSObject* nwh = (NSObject*)g_platformData.nwh;
|
|
|
m_context = g_platformData.context;
|
|
m_context = g_platformData.context;
|
|
|
|
|
|
|
|
|
|
+ NSWindow* nsWindow = nil;
|
|
|
|
|
+ NSView* contentView = nil;
|
|
|
|
|
+ if ([nwh isKindOfClass:[NSView class]])
|
|
|
|
|
+ {
|
|
|
|
|
+ contentView = (NSView*)nwh;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if ([nwh isKindOfClass:[NSWindow class]])
|
|
|
|
|
+ {
|
|
|
|
|
+ nsWindow = (NSWindow*)nwh;
|
|
|
|
|
+ contentView = [nsWindow contentView];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (NULL == g_platformData.context)
|
|
if (NULL == g_platformData.context)
|
|
|
{
|
|
{
|
|
|
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
|
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
|
@@ -99,14 +111,13 @@ namespace bgfx { namespace gl
|
|
|
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
|
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
|
|
|
BGFX_FATAL(NULL != pixelFormat, Fatal::UnableToInitialize, "Failed to initialize pixel format.");
|
|
BGFX_FATAL(NULL != pixelFormat, Fatal::UnableToInitialize, "Failed to initialize pixel format.");
|
|
|
|
|
|
|
|
- NSRect glViewRect = [[nsWindow contentView] bounds];
|
|
|
|
|
|
|
+ NSRect glViewRect = [contentView bounds];
|
|
|
NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat];
|
|
NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat];
|
|
|
|
|
|
|
|
[pixelFormat release];
|
|
[pixelFormat release];
|
|
|
// GLFW creates a helper contentView that handles things like keyboard and drag and
|
|
// GLFW creates a helper contentView that handles things like keyboard and drag and
|
|
|
// drop events. We don't want to clobber that view if it exists. Instead we just
|
|
// drop events. We don't want to clobber that view if it exists. Instead we just
|
|
|
// add ourselves as a subview and make the view resize automatically.
|
|
// add ourselves as a subview and make the view resize automatically.
|
|
|
- NSView *contentView = [nsWindow contentView];
|
|
|
|
|
if (nil != contentView)
|
|
if (nil != contentView)
|
|
|
{
|
|
{
|
|
|
[glView setAutoresizingMask:( NSViewHeightSizable |
|
|
[glView setAutoresizingMask:( NSViewHeightSizable |
|
|
@@ -119,7 +130,8 @@ namespace bgfx { namespace gl
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- [nsWindow setContentView:glView];
|
|
|
|
|
|
|
+ if (nil != nsWindow)
|
|
|
|
|
+ [nsWindow setContentView:glView];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
NSOpenGLContext* glContext = [glView openGLContext];
|
|
NSOpenGLContext* glContext = [glView openGLContext];
|
|
@@ -179,8 +191,8 @@ namespace bgfx { namespace gl
|
|
|
{
|
|
{
|
|
|
uint64_t caps = 0;
|
|
uint64_t caps = 0;
|
|
|
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
|
#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
|
|
- NSWindow* nsWindow = (NSWindow*)g_platformData.nwh;
|
|
|
|
|
- if ([nsWindow respondsToSelector:@selector(backingScaleFactor)] && (1.0f < [nsWindow backingScaleFactor]))
|
|
|
|
|
|
|
+ NSObject* nwh = (NSObject*)g_platformData.nwh;
|
|
|
|
|
+ if ([nwh respondsToSelector:@selector(backingScaleFactor)] && (1.0f < [nwh backingScaleFactor]))
|
|
|
caps |= BGFX_CAPS_HIDPI;
|
|
caps |= BGFX_CAPS_HIDPI;
|
|
|
#endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
|
#endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
|
|
|
return caps;
|
|
return caps;
|