Add winapi to do another cast

This commit is contained in:
maik klein 2016-12-26 02:35:43 +01:00
parent 150e32a7c6
commit 28f809ef80
3 changed files with 6 additions and 2 deletions

1
examples/Cargo.lock generated
View file

@ -5,6 +5,7 @@ dependencies = [
"ash 0.2.0",
"image 0.10.4 (registry+https://github.com/rust-lang/crates.io-index)",
"user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winit 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)",
]

View file

@ -10,3 +10,4 @@ ash = { version = "*", path = "../"}
[target.'cfg(windows)'.dependencies]
user32-sys = "0.2.0"
winapi = "0.2.8"

View file

@ -4,6 +4,8 @@ extern crate ash;
extern crate winit;
#[cfg(windows)]
extern crate user32;
#[cfg(windows)]
extern crate winapi;
use ash::vk;
use std::default::Default;
@ -101,14 +103,14 @@ fn create_surface(instance: &Instance,
window: &winit::Window)
-> Result<vk::SurfaceKHR, vk::Result> {
use winit::os::windows::WindowExt;
let hwnd = window.get_hwnd() as *const ();
let hwnd = window.get_hwnd() as *mut winapi::windef::HWND__;
let hinstance = user32::GetWindow(hwnd, 0) as *const ();
let win32_create_info = vk::Win32SurfaceCreateInfoKHR {
s_type: vk::StructureType::Win32SurfaceCreateInfoKhr,
p_next: ptr::null(),
flags: Default::default(),
hinstance: hinstance,
hwnd: hwnd,
hwnd: hwnd as *const (),
};
let win32_surface_loader = Win32Surface::new(&entry, &instance)
.expect("Unable to load win32 surface");