ash-window: Upgrade winit
example to 0.26
This commit is contained in:
parent
c66db26bc3
commit
f4acfbe2cb
|
@ -22,7 +22,7 @@ raw-window-handle = "0.3.4"
|
||||||
raw-window-metal = "0.1"
|
raw-window-metal = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
winit = "0.19.4"
|
winit = "0.26"
|
||||||
ash = { path = "../ash", version = "0.37", default-features = false, features = ["linked"] }
|
ash = { path = "../ash", version = "0.37", default-features = false, features = ["linked"] }
|
||||||
|
|
||||||
[[example]]
|
[[example]]
|
||||||
|
|
|
@ -7,12 +7,18 @@
|
||||||
|
|
||||||
use ash::vk;
|
use ash::vk;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use winit::{
|
||||||
|
dpi::PhysicalSize,
|
||||||
|
event::{Event, VirtualKeyCode, WindowEvent},
|
||||||
|
event_loop::{ControlFlow, EventLoop},
|
||||||
|
window::WindowBuilder,
|
||||||
|
};
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let mut events_loop = winit::EventsLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
let window = winit::WindowBuilder::new()
|
let window = WindowBuilder::new()
|
||||||
.with_dimensions((800, 600).into())
|
.with_inner_size(PhysicalSize::<u32>::from((800, 600)))
|
||||||
.build(&events_loop)?;
|
.build(&event_loop)?;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let entry = ash::Entry::linked();
|
let entry = ash::Entry::linked();
|
||||||
|
@ -29,21 +35,26 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let surface_fn = ash::extensions::khr::Surface::new(&entry, &instance);
|
let surface_fn = ash::extensions::khr::Surface::new(&entry, &instance);
|
||||||
println!("surface: {:?}", surface);
|
println!("surface: {:?}", surface);
|
||||||
|
|
||||||
let mut running = true;
|
event_loop.run(move |event, _, control_flow| match event {
|
||||||
while running {
|
winit::event::Event::WindowEvent {
|
||||||
events_loop.poll_events(|event| {
|
event:
|
||||||
if let winit::Event::WindowEvent {
|
WindowEvent::CloseRequested
|
||||||
event: winit::WindowEvent::CloseRequested,
|
| WindowEvent::KeyboardInput {
|
||||||
..
|
input:
|
||||||
} = event
|
winit::event::KeyboardInput {
|
||||||
{
|
virtual_keycode: Some(VirtualKeyCode::Escape),
|
||||||
running = false;
|
..
|
||||||
}
|
},
|
||||||
});
|
..
|
||||||
}
|
},
|
||||||
|
window_id: _,
|
||||||
surface_fn.destroy_surface(surface, None);
|
} => {
|
||||||
|
*control_flow = ControlFlow::Exit;
|
||||||
|
}
|
||||||
|
Event::LoopDestroyed => {
|
||||||
|
surface_fn.destroy_surface(surface, None);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue