From 3272509ae50ed30211c11dd7ea2ee2249feac948 Mon Sep 17 00:00:00 2001 From: Steve Browne Date: Fri, 25 Oct 2019 04:10:18 +0200 Subject: [PATCH] Prevent default OpenGL context creation in wxGLCanvas under macOS This renders unnecessary the previous workarounds for using NSOpenGLView as the base class for wxGLCanvas view, so revert them. See: - 2ab430965c457de680d3a3ea37445b7dfa0090e0 which introduced the use of NSOpenGLView (see https://github.com/wxWidgets/wxWidgets/pull/846). - ea68934b8e3374d03e876f56a1637663de351cb7 for the first workaround due to the use of NSOpenGLView and its default context creation. - 6974a6ceaa8f81168459119f98d7ed9a03b1c88d for the refinement of the workaround above. - e6ae83c386427b1cd2840e5f8059310e8b4fb3ea and b822e9efe8f35e1683665332cf21f941be89404e which tweaked it futher. This commit renders unnecessary all the changes since the initial switch to NSOpenGLView by just preventing NSOpenGLView from creating its own context and thus enforcing the use of wxGLContext associated with wxGLCanvas. Closes https://github.com/wxWidgets/wxWidgets/pull/1617 --- src/osx/cocoa/glcanvas.mm | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index b2df34d9df..505b3a5e4b 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -150,6 +150,13 @@ WXGLPixelFormat WXGLChoosePixelFormat(const int *GLAttrs, impl->doCommandBySelector(aSelector, self, _cmd); } +- (NSOpenGLContext *) openGLContext +{ + // Prevent the NSOpenGLView from making it's own context + // We want to force using wxGLContexts + return NULL; +} + @end bool wxGLCanvas::DoCreate(wxWindow *parent, @@ -201,24 +208,6 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const [m_glContext makeCurrentContext]; - // the missing redraw upon resize problem only happens when linked against 10.14 -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 - // At least under macOS 10.14.5 we need to do this in order to update the - // context with the new size information after the window is resized. - if ( WX_IS_MACOS_AVAILABLE_FULL(10, 14, 5) ) - { - if ( WX_IS_MACOS_AVAILABLE(10, 15) ) - { - // no workaround needed under 10.15 anymore - } - else - { - NSOpenGLView *v = (NSOpenGLView *)win.GetHandle(); - [v setOpenGLContext: m_glContext]; - } - } -#endif - return true; }