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" }
cgmath = "0.7.0"
image = "0.6.1"
winit = "0.5.0"
winit = "0.5.1"
[build-dependencies]
vk-sys = { path = "../vk-sys" }

View File

@ -8,4 +8,4 @@ license = "MIT/Apache-2.0"
[dependencies]
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_android_surface: true,
khr_win32_surface: true,
.. InstanceExtensions::none()
..InstanceExtensions::none()
};
let supported = InstanceExtensions::supported_by_core();
@ -111,26 +111,35 @@ impl From<WindowCreationError> for CreationError {
}
#[cfg(target_os = "android")]
unsafe fn winit_to_surface(instance: &Arc<Instance>, win: &winit::Window)
-> Result<Arc<Surface>, SurfaceCreationError>
{
unsafe fn winit_to_surface(instance: &Arc<Instance>,
win: &winit::Window)
-> Result<Arc<Surface>, SurfaceCreationError> {
use winit::os::android::WindowExt;
Surface::from_anativewindow(instance, win.get_native_window())
}
#[cfg(all(unix, not(target_os = "android")))]
unsafe fn winit_to_surface(instance: &Arc<Instance>, win: &winit::Window)
-> Result<Arc<Surface>, SurfaceCreationError>
{
unsafe fn winit_to_surface(instance: &Arc<Instance>,
win: &winit::Window)
-> Result<Arc<Surface>, SurfaceCreationError> {
use winit::os::unix::WindowExt;
Surface::from_xlib(instance, win.get_xlib_display().unwrap(),
win.get_xlib_window().unwrap())
match (win.get_wayland_display(), win.get_wayland_surface()) {
(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)]
unsafe fn winit_to_surface(instance: &Arc<Instance>, win: &winit::Window)
-> Result<Arc<Surface>, SurfaceCreationError>
{
unsafe fn winit_to_surface(instance: &Arc<Instance>,
win: &winit::Window)
-> Result<Arc<Surface>, SurfaceCreationError> {
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())
}