raw-window-handle 0.6
This commit is contained in:
parent
66c0cf42a0
commit
55628b4023
|
@ -16,14 +16,16 @@ rust-version = "1.64.0"
|
|||
|
||||
[dependencies]
|
||||
ash = { path = "../ash", version = "0.37", default-features = false }
|
||||
raw-window-handle = "0.5"
|
||||
raw-window-handle = "0.6"
|
||||
|
||||
[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
|
||||
raw-window-metal = "0.3"
|
||||
raw-window-metal = "0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
winit = "0.27.1"
|
||||
ash = { path = "../ash", version = "0.37", default-features = false, features = ["linked"] }
|
||||
ash = { path = "../ash", version = "0.37", default-features = false, features = [
|
||||
"linked",
|
||||
] }
|
||||
|
||||
[[example]]
|
||||
name = "winit"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#![warn(trivial_casts, trivial_numeric_casts)]
|
||||
|
||||
use std::os::raw::c_char;
|
||||
use std::{ffi::c_void, os::raw::c_char};
|
||||
|
||||
use ash::{
|
||||
extensions::{ext, khr},
|
||||
|
@ -42,23 +42,29 @@ pub unsafe fn create_surface(
|
|||
match (display_handle, window_handle) {
|
||||
(RawDisplayHandle::Windows(_), RawWindowHandle::Win32(window)) => {
|
||||
let surface_desc = vk::Win32SurfaceCreateInfoKHR::builder()
|
||||
.hinstance(window.hinstance)
|
||||
.hwnd(window.hwnd);
|
||||
.hinstance(window.hinstance.ok_or(vk::Result::ERROR_UNKNOWN)?.get() as *mut c_void)
|
||||
.hwnd(window.hwnd.get() as *mut c_void);
|
||||
let surface_fn = khr::Win32Surface::new(entry, instance);
|
||||
surface_fn.create_win32_surface(&surface_desc, allocation_callbacks)
|
||||
}
|
||||
|
||||
(RawDisplayHandle::Wayland(display), RawWindowHandle::Wayland(window)) => {
|
||||
let surface_desc = vk::WaylandSurfaceCreateInfoKHR::builder()
|
||||
.display(display.display)
|
||||
.surface(window.surface);
|
||||
.display(display.display.as_ptr())
|
||||
.surface(window.surface.as_ptr());
|
||||
let surface_fn = khr::WaylandSurface::new(entry, instance);
|
||||
surface_fn.create_wayland_surface(&surface_desc, allocation_callbacks)
|
||||
}
|
||||
|
||||
(RawDisplayHandle::Xlib(display), RawWindowHandle::Xlib(window)) => {
|
||||
let surface_desc = vk::XlibSurfaceCreateInfoKHR::builder()
|
||||
.dpy(display.display.cast())
|
||||
.dpy(
|
||||
display
|
||||
.display
|
||||
.ok_or(vk::Result::ERROR_UNKNOWN)?
|
||||
.as_ptr()
|
||||
.cast(),
|
||||
)
|
||||
.window(window.window);
|
||||
let surface_fn = khr::XlibSurface::new(entry, instance);
|
||||
surface_fn.create_xlib_surface(&surface_desc, allocation_callbacks)
|
||||
|
@ -66,15 +72,20 @@ pub unsafe fn create_surface(
|
|||
|
||||
(RawDisplayHandle::Xcb(display), RawWindowHandle::Xcb(window)) => {
|
||||
let surface_desc = vk::XcbSurfaceCreateInfoKHR::builder()
|
||||
.connection(display.connection)
|
||||
.window(window.window);
|
||||
.connection(
|
||||
display
|
||||
.connection
|
||||
.ok_or(vk::Result::ERROR_UNKNOWN)?
|
||||
.as_ptr(),
|
||||
)
|
||||
.window(window.window.get());
|
||||
let surface_fn = khr::XcbSurface::new(entry, instance);
|
||||
surface_fn.create_xcb_surface(&surface_desc, allocation_callbacks)
|
||||
}
|
||||
|
||||
(RawDisplayHandle::Android(_), RawWindowHandle::AndroidNdk(window)) => {
|
||||
let surface_desc =
|
||||
vk::AndroidSurfaceCreateInfoKHR::builder().window(window.a_native_window);
|
||||
vk::AndroidSurfaceCreateInfoKHR::builder().window(window.a_native_window.as_ptr());
|
||||
let surface_fn = khr::AndroidSurface::new(entry, instance);
|
||||
surface_fn.create_android_surface(&surface_desc, allocation_callbacks)
|
||||
}
|
||||
|
@ -85,7 +96,7 @@ pub unsafe fn create_surface(
|
|||
|
||||
let layer = match appkit::metal_layer_from_handle(window) {
|
||||
Layer::Existing(layer) | Layer::Allocated(layer) => layer.cast(),
|
||||
Layer::None => return Err(vk::Result::ERROR_INITIALIZATION_FAILED),
|
||||
// Layer::None => return Err(vk::Result::ERROR_INITIALIZATION_FAILED),
|
||||
};
|
||||
|
||||
let surface_desc = vk::MetalSurfaceCreateInfoEXT::builder().layer(&*layer);
|
||||
|
|
Loading…
Reference in a new issue