diff --git a/src/gl/macos.rs b/src/gl/macos.rs index 0610879..215dd94 100644 --- a/src/gl/macos.rs +++ b/src/gl/macos.rs @@ -11,6 +11,7 @@ use cocoa::appkit::{ NSOpenGLProfileVersionLegacy, NSOpenGLView, NSView, }; use cocoa::base::{id, nil, YES}; +use cocoa::foundation::NSSize; use core_foundation::base::TCFType; use core_foundation::bundle::{CFBundleGetBundleWithIdentifier, CFBundleGetFunctionPointerForName}; @@ -134,6 +135,14 @@ impl GlContext { let () = msg_send![self.view, setNeedsDisplay: YES]; } } + + /// On macOS the `NSOpenGLView` needs to be resized separtely from our main view. + pub(crate) fn resize(&self, size: NSSize) { + unsafe { NSView::setFrameSize(self.view, size) }; + unsafe { + let _: () = msg_send![self.view, setNeedsDisplay: YES]; + } + } } impl Drop for GlContext { diff --git a/src/gl/mod.rs b/src/gl/mod.rs index a7922b7..adfc12d 100644 --- a/src/gl/mod.rs +++ b/src/gl/mod.rs @@ -106,4 +106,10 @@ impl GlContext { pub fn swap_buffers(&self) { self.context.swap_buffers(); } + + /// On macOS the `NSOpenGLView` needs to be resized separtely from our main view. + #[cfg(target_os = "macos")] + pub(crate) fn resize(&self, size: cocoa::foundation::NSSize) { + self.context.resize(size); + } }