diff --git a/vulkano-win/src/raw_window_handle.rs b/vulkano-win/src/raw_window_handle.rs index b758a0b0..95081547 100644 --- a/vulkano-win/src/raw_window_handle.rs +++ b/vulkano-win/src/raw_window_handle.rs @@ -9,24 +9,22 @@ use std::ffi::c_void; use std::os::raw::c_ulong; use std::sync::Arc; -use raw_window_handle::RawWindowHandle; +use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; use vulkano::instance::Instance; use vulkano::swapchain::Surface; use vulkano::swapchain::SurfaceCreationError; -/// Creates a vulkan surface from an os-dependent handle -/// window here is a generic type for a Window which can be handed over -/// to ensure that it will be dropped after the surface +/// Creates a vulkan surface from a generic window +/// which implements HasRawWindowHandle and thus can reveal the os-dependent handle pub fn create_vk_surface_from_handle( window: W, - handle: RawWindowHandle, instance: Arc, ) -> Result>, SurfaceCreationError> where - W: Sized, + W: HasRawWindowHandle, { unsafe { - match handle { + match window.raw_window_handle(){ #[cfg(target_os = "ios")] RawWindowHandle::IOS(h) => handle_to_surface(h.ui_view, instance, window), #[cfg(target_os = "macos")] diff --git a/vulkano-win/src/winit.rs b/vulkano-win/src/winit.rs index f6979411..4753723a 100644 --- a/vulkano-win/src/winit.rs +++ b/vulkano-win/src/winit.rs @@ -179,7 +179,7 @@ unsafe fn winit_to_surface>( Surface::from_hwnd( instance, - ptr::null() as *const (), // FIXME + win.borrow().hinstance(), win.borrow().hwnd(), win, )