diff --git a/examples/Cargo.toml b/examples/Cargo.toml index f00b9689e..d8ab66aaa 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -49,6 +49,7 @@ pango-cairo = ["pango", "pangocairo", "cairo-rs"] gl = ["gl_generator", "glutin"] gl-egl = ["gstreamer-gl/egl"] gl-x11 = ["gstreamer-gl/x11"] +gl-wayland = ["gstreamer-gl/wayland"] [[bin]] name = "appsink" @@ -140,4 +141,4 @@ required-features = ["ges"] [[bin]] name = "glupload" required-features = ["gl"] -features = ["gl-egl", "gl-x11"] +features = ["gl-egl", "gl-x11", "gl-wayland"] diff --git a/examples/src/bin/glupload.rs b/examples/src/bin/glupload.rs index 3e9d5f919..cfc3071a8 100644 --- a/examples/src/bin/glupload.rs +++ b/examples/src/bin/glupload.rs @@ -355,18 +355,23 @@ impl App { let windowed_context_ = windowed_context.clone(); let context = windowed_context_.context(); + + #[cfg(any(feature = "gl-x11", feature = "gl-wayland"))] let inner_window = windowed_context_.window(); let shared_context: gst_gl::GLContext; if cfg!(target_os = "linux") { use glutin::os::unix::RawHandle; + #[cfg(any(feature = "gl-x11", feature = "gl-wayland"))] + use glutin::os::unix::WindowExt; use glutin::os::ContextTraitExt; let api = App::map_gl_api(context.get_api()); let (gl_context, gl_display, platform) = match unsafe { context.raw_handle() } { - #[cfg(feature = "gl-egl")] + #[cfg(any(feature = "gl-egl", feature = "gl-wayland"))] RawHandle::Egl(egl_context) => { + #[cfg(feature = "gl-egl")] let gl_display = if let Some(display) = unsafe { context.get_egl_display() } { unsafe { gst_gl::GLDisplayEGL::new_with_egl_display(display as usize) } .unwrap() @@ -374,6 +379,14 @@ impl App { panic!("EGL context without EGL display"); }; + #[cfg(not(feature = "gl-egl"))] + let gl_display = if let Some(display) = inner_window.get_wayland_display() { + unsafe { gst_gl::GLDisplayWayland::new_with_display(display as usize) } + .unwrap() + } else { + panic!("Wayland window without Wayland display"); + }; + ( egl_context as usize, gl_display.upcast::(), @@ -382,8 +395,6 @@ impl App { } #[cfg(feature = "gl-x11")] RawHandle::Glx(glx_context) => { - use glutin::os::unix::WindowExt; - let gl_display = if let Some(display) = inner_window.get_xlib_display() { unsafe { gst_gl::GLDisplayX11::new_with_display(display as usize) }.unwrap() } else { @@ -396,7 +407,7 @@ impl App { gst_gl::GLPlatform::GLX, ) } - _ => panic!("Unsupported platform"), + handler => panic!("Unsupported platform: {:?}.", handler), }; shared_context =