Merge pull request #114 from nicokoch/wayland-support

Window creation: Add support for wayland on unixes
This commit is contained in:
tomaka 2016-05-24 14:02:28 +02:00
commit 89394324d1
3 changed files with 24 additions and 15 deletions

View File

@ -9,7 +9,7 @@ vulkano = { path = "../vulkano" }
vulkano-win = { path = "../vulkano-win" } vulkano-win = { path = "../vulkano-win" }
cgmath = "0.7.0" cgmath = "0.7.0"
image = "0.6.1" image = "0.6.1"
winit = "0.5.0" winit = "0.5.1"
[build-dependencies] [build-dependencies]
vk-sys = { path = "../vk-sys" } vk-sys = { path = "../vk-sys" }

View File

@ -8,4 +8,4 @@ license = "MIT/Apache-2.0"
[dependencies] [dependencies]
vulkano = { version = "0.1.0", path = "../vulkano" } vulkano = { version = "0.1.0", path = "../vulkano" }
winit = "0.5.0" winit = "0.5.1"

View File

@ -22,7 +22,7 @@ pub fn required_extensions() -> InstanceExtensions {
khr_mir_surface: true, khr_mir_surface: true,
khr_android_surface: true, khr_android_surface: true,
khr_win32_surface: true, khr_win32_surface: true,
.. InstanceExtensions::none() ..InstanceExtensions::none()
}; };
let supported = InstanceExtensions::supported_by_core(); let supported = InstanceExtensions::supported_by_core();
@ -111,26 +111,35 @@ impl From<WindowCreationError> for CreationError {
} }
#[cfg(target_os = "android")] #[cfg(target_os = "android")]
unsafe fn winit_to_surface(instance: &Arc<Instance>, win: &winit::Window) unsafe fn winit_to_surface(instance: &Arc<Instance>,
-> Result<Arc<Surface>, SurfaceCreationError> win: &winit::Window)
{ -> Result<Arc<Surface>, SurfaceCreationError> {
use winit::os::android::WindowExt; use winit::os::android::WindowExt;
Surface::from_anativewindow(instance, win.get_native_window()) Surface::from_anativewindow(instance, win.get_native_window())
} }
#[cfg(all(unix, not(target_os = "android")))] #[cfg(all(unix, not(target_os = "android")))]
unsafe fn winit_to_surface(instance: &Arc<Instance>, win: &winit::Window) unsafe fn winit_to_surface(instance: &Arc<Instance>,
-> Result<Arc<Surface>, SurfaceCreationError> win: &winit::Window)
{ -> Result<Arc<Surface>, SurfaceCreationError> {
use winit::os::unix::WindowExt; use winit::os::unix::WindowExt;
Surface::from_xlib(instance, win.get_xlib_display().unwrap(), match (win.get_wayland_display(), win.get_wayland_surface()) {
win.get_xlib_window().unwrap()) (Some(display), Some(surface)) => Surface::from_wayland(instance, display, surface),
_ => {
// No wayland display found, assume xlib will work.
Surface::from_xlib(instance,
win.get_xlib_display().unwrap(),
win.get_xlib_window().unwrap())
}
}
} }
#[cfg(windows)] #[cfg(windows)]
unsafe fn winit_to_surface(instance: &Arc<Instance>, win: &winit::Window) unsafe fn winit_to_surface(instance: &Arc<Instance>,
-> Result<Arc<Surface>, SurfaceCreationError> win: &winit::Window)
{ -> Result<Arc<Surface>, SurfaceCreationError> {
use winit::os::windows::WindowExt; use winit::os::windows::WindowExt;
Surface::from_hwnd(instance, ptr::null() as *const () /* FIXME */, win.get_hwnd()) Surface::from_hwnd(instance,
ptr::null() as *const (), // FIXME
win.get_hwnd())
} }