diff --git a/examples/Cargo.toml b/examples/Cargo.toml index ddd34b717..79ff3abf9 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -26,7 +26,6 @@ gtk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true } gdk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true } gio = { git = "https://github.com/gtk-rs/gtk-rs", optional = true } anyhow = "1.0" -cfg-if = "1.0" derive_more = "0.99.5" futures = "0.3" byte-slice-cast = "1" diff --git a/examples/src/bin/glupload.rs b/examples/src/bin/glupload.rs index b86e28f8e..f94f4d4da 100644 --- a/examples/src/bin/glupload.rs +++ b/examples/src/bin/glupload.rs @@ -356,27 +356,31 @@ impl App { { #[cfg(any(feature = "gst-gl-egl", feature = "gst-gl-wayland"))] RawHandle::Egl(egl_context) => { - cfg_if::cfg_if! { - if #[cfg(feature = "gst-gl-egl")] { - let gl_display = if let Some(display) = - unsafe { windowed_context.get_egl_display() } - { - unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(display as usize) }.unwrap() - } else { - panic!("EGL context without EGL display"); - }; - } else if #[cfg(feature = "gst-gl-wayland")] { - let gl_display = if let Some(display) = inner_window.get_wayland_display() { - unsafe { gst_gl_wayland::GLDisplayWayland::with_display(display as usize) }.unwrap() - } else { - panic!("Wayland window without Wayland display"); - }; - } - } + let mut gl_display = None; + + #[cfg(feature = "gst-gl-egl")] + if let Some(display) = unsafe { windowed_context.get_egl_display() } { + gl_display = Some( + unsafe { gst_gl_egl::GLDisplayEGL::with_egl_display(display as usize) } + .unwrap() + .upcast::(), + ) + }; + + #[cfg(feature = "gst-gl-wayland")] + if let Some(display) = inner_window.get_wayland_display() { + gl_display = Some( + unsafe { + gst_gl_wayland::GLDisplayWayland::with_display(display as usize) + } + .unwrap() + .upcast::(), + ) + }; ( egl_context as usize, - gl_display.upcast::(), + gl_display.expect("Could not retrieve GLDisplay through EGL context and/or Wayland display"), gst_gl::GLPlatform::EGL, ) }