Skip to content

Commit baaf31a

Browse files
committed
Switch from ndk_glue to raw-window-handle
1 parent 232c69e commit baaf31a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

glutin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ winit = { version = "0.26", default-features = false }
2727
[target.'cfg(target_os = "android")'.dependencies]
2828
glutin_egl_sys = { version = "0.1.5", path = "../glutin_egl_sys" }
2929
libloading = "0.7"
30-
ndk-glue = "0.5"
3130
parking_lot = "0.11"
31+
raw-window-handle = "0.4"
3232

3333
[target.'cfg(target_os = "emscripten")'.dependencies]
3434
glutin_emscripten_sys = { version = "0.1.1", path = "../glutin_emscripten_sys" }

glutin/src/api/android/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{Api, ContextError, GlAttributes, PixelFormat, PixelFormatRequirement
66

77
use glutin_egl_sys as ffi;
88
use parking_lot::Mutex;
9+
use raw_window_handle::{AndroidNdkHandle, HasRawWindowHandle, RawWindowHandle};
910
use winit;
1011
use winit::dpi;
1112
use winit::event_loop::EventLoopWindowTarget;
@@ -32,14 +33,20 @@ impl Context {
3233
) -> Result<(winit::window::Window, Self), CreationError> {
3334
let win = wb.build(el)?;
3435
let gl_attr = gl_attr.clone().map_sharing(|c| &c.0.egl_context);
35-
let nwin = ndk_glue::native_window();
36-
let nwin = nwin.as_ref().ok_or_else(|| OsError("Android's native window is null".to_string()))?;
36+
let nwin =
37+
if let RawWindowHandle::AndroidNdk(AndroidNdkHandle { a_native_window, .. }) =
38+
win.raw_window_handle()
39+
{
40+
a_native_window
41+
} else {
42+
return Err(OsError("raw_window_handle() is not for Android".to_string()));
43+
};
3744
let native_display = NativeDisplay::Android;
3845
let egl_context =
3946
EglContext::new(pf_reqs, &gl_attr, native_display, EglSurfaceType::Window, |c, _| {
4047
Ok(c[0])
4148
})
42-
.and_then(|p| p.finish(nwin.ptr().as_ptr() as *const _))?;
49+
.and_then(|p| p.finish(nwin))?;
4350
let ctx = Arc::new(AndroidContext { egl_context, stopped: Some(Mutex::new(false)) });
4451

4552
let context = Context(ctx.clone());

0 commit comments

Comments
 (0)