1
0
Fork 0

Also resize the OpenGL view on macOS

This fixes resizing with OpenGL applications.
This commit is contained in:
Robbert van der Helm 2022-12-02 19:54:18 +01:00
parent e0c79c58fb
commit c7b61fa39b
2 changed files with 15 additions and 0 deletions

View file

@ -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 {

View file

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