summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src/glcontext_nsgl.mm
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/src/glcontext_nsgl.mm')
-rw-r--r--3rdparty/bgfx/src/glcontext_nsgl.mm28
1 files changed, 21 insertions, 7 deletions
diff --git a/3rdparty/bgfx/src/glcontext_nsgl.mm b/3rdparty/bgfx/src/glcontext_nsgl.mm
index af35e9c5ebf..db483528644 100644
--- a/3rdparty/bgfx/src/glcontext_nsgl.mm
+++ b/3rdparty/bgfx/src/glcontext_nsgl.mm
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2018 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -11,6 +11,8 @@
# include <Cocoa/Cocoa.h>
# include <bx/os.h>
+BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wdeprecated-declarations")
+
namespace bgfx { namespace gl
{
@@ -65,9 +67,21 @@ namespace bgfx { namespace gl
BX_CHECK(NULL != s_opengl, "OpenGL dynamic library is not found!");
const AutoreleasePoolHolder pool;
- NSWindow* nsWindow = (NSWindow*)g_platformData.nwh;
+ NSObject* nwh = (NSObject*)g_platformData.nwh;
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 defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
@@ -97,14 +111,13 @@ namespace bgfx { namespace gl
NSOpenGLPixelFormat* pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttributes];
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];
[pixelFormat release];
// 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
// add ourselves as a subview and make the view resize automatically.
- NSView *contentView = [nsWindow contentView];
if (nil != contentView)
{
[glView setAutoresizingMask:( NSViewHeightSizable |
@@ -117,7 +130,8 @@ namespace bgfx { namespace gl
}
else
{
- [nsWindow setContentView:glView];
+ if (nil != nsWindow)
+ [nsWindow setContentView:glView];
}
NSOpenGLContext* glContext = [glView openGLContext];
@@ -177,8 +191,8 @@ namespace bgfx { namespace gl
{
uint64_t caps = 0;
#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 < [(id)nwh backingScaleFactor]))
caps |= BGFX_CAPS_HIDPI;
#endif // defined(MAC_OS_X_VERSION_MAX_ALLOWED) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)
return caps;