Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.65k stars 465 forks source link

Incompatible with wgpu 1.9.0+ #1376

Closed jordan4ibanez closed 2 weeks ago

jordan4ibanez commented 3 months ago
the trait bound `sdl2::video::Window: HasWindowHandle` is not satisfied
the following other types implement trait `HasWindowHandle`:
  Box<H>
  wgpu::raw_window_handle::WindowHandle<'_>
  Rc<H>
  Arc<H>
  &H
  &mut H
required for `&sdl2::video::Window` to implement `HasWindowHandle`
required for `&sdl2::video::Window` to implement `wgpu::WindowHandle`
required for `SurfaceTarget<'_>` to implement `From<&sdl2::video::Window>`
required for `&sdl2::video::Window` to implement `Into<SurfaceTarget<'_>>`

This leaves it stuck back in versions before wgpu 1.9.0.

This is the minimal reproducible environment:

///
/// Attempts to link the SDL2 window into wgpu to create a surface.
///
pub fn link_wgpu_to_sdl2<'a>(
  instance: &'a wgpu::Instance,
  window: &'a sdl2::video::Window,
) -> Result<wgpu::Surface<'a>, wgpu::CreateSurfaceError> {
  unsafe { instance.create_surface(window) }
}
daniel-lacour commented 2 months ago

Glad to know I wasn't the only one dealing with this.

jordan4ibanez commented 2 months ago

Yeah, this was quiet frustrating. I looked into it a while back and for the life of me cannot figure out what changes are needed to make it work.