From 6974a6ceaa8f81168459119f98d7ed9a03b1c88d Mon Sep 17 00:00:00 2001 From: Daniel Kulp Date: Tue, 20 Aug 2019 11:17:49 +0200 Subject: [PATCH] Really fix problems with wxGLCanvas resizing under macOS 10.14.5 This is a better fix for the problem with NSOpenGLView having wrong size after resizing the window under 10.14.5 (only): reset the context when making the context current, to ensure that the up-to-date size is used. See #18402. --- src/osx/cocoa/glcanvas.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/osx/cocoa/glcanvas.mm b/src/osx/cocoa/glcanvas.mm index 59c572e73b..44646ba9c8 100644 --- a/src/osx/cocoa/glcanvas.mm +++ b/src/osx/cocoa/glcanvas.mm @@ -33,6 +33,7 @@ #endif #include "wx/osx/private.h" +#include "wx/osx/private/available.h" WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext ) { @@ -199,6 +200,14 @@ bool wxGLContext::SetCurrent(const wxGLCanvas& win) const [m_glContext makeCurrentContext]; + // 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) ) + { + NSOpenGLView *v = (NSOpenGLView *)win.GetHandle(); + [v setOpenGLContext: m_glContext]; + } + return true; }