Skip to content

Commit

Permalink
Angle support on macOS (gfx-rs#2461)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinleili authored and kolen committed Feb 14, 2022
1 parent a196670 commit 215c12f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,19 @@ impl crate::Surface<super::Api> for Surface {
window
}
(WindowKind::Unknown, Rwh::Win32(handle)) => handle.hwnd,
(WindowKind::Unknown, Rwh::AppKit(handle)) => handle.ns_view,
(WindowKind::Unknown, Rwh::AppKit(handle)) => {
#[cfg(not(target_os = "macos"))]
let window_ptr = handle.ns_view;
#[cfg(target_os = "macos")]
let window_ptr = {
use objc::{msg_send, runtime::Object, sel, sel_impl};
// ns_view always have a layer and don't need to verify that it exists.
let layer: *mut Object =
msg_send![handle.ns_view as *mut Object, layer];
layer as *mut std::ffi::c_void
};
window_ptr
}
_ => {
log::warn!(
"Initialized platform {:?} doesn't work with window {:?}",
Expand All @@ -964,7 +976,7 @@ impl crate::Surface<super::Api> for Surface {
// We don't want any of the buffering done by the driver, because we
// manage a swapchain on our side.
// Some drivers just fail on surface creation seeing `EGL_SINGLE_BUFFER`.
if cfg!(target_os = "android")
if cfg!(any(target_os = "android", target_os = "macos"))
|| cfg!(windows)
|| self.wsi.kind == WindowKind::AngleX11
{
Expand Down

0 comments on commit 215c12f

Please sign in to comment.