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
This commit is contained in:
Steve Browne 2019-10-25 04:10:18 +02:00 committed by Vadim Zeitlin
parent b97bf311e0
commit 3272509ae5

View File

@ -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;
}