mirror of
https://github.com/vulkano-rs/vulkano.git
synced 2024-11-22 06:45:23 +00:00
Improve vulkano-win (#1386)
* Use winit's hinstance() function * Require HasRawWindowHandle for the window and remove handle parameter Co-authored-by: Antonino Siena <a.siena@gmx.de>
This commit is contained in:
parent
c5dd6eda3e
commit
b0c8eca283
@ -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<W>(
|
||||
window: W,
|
||||
handle: RawWindowHandle,
|
||||
instance: Arc<Instance>,
|
||||
) -> Result<Arc<Surface<W>>, 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")]
|
||||
|
@ -179,7 +179,7 @@ unsafe fn winit_to_surface<W: SafeBorrow<Window>>(
|
||||
|
||||
Surface::from_hwnd(
|
||||
instance,
|
||||
ptr::null() as *const (), // FIXME
|
||||
win.borrow().hinstance(),
|
||||
win.borrow().hwnd(),
|
||||
win,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user