mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Merge #152
152: Update to latest winit (0.20.0-alpha6) r=kvark a=grovesNL Updated to latest winit to fix examples: - `RedrawRequested` is now used for rendering - `EventsCleared` replaced by `MainEventsCleared` which requests redraw - Removed Metal auto-capture and escape key handling from hello-triangle to simplify the example slightly (it doesn't use `framework`, so we should try to make it as simple as possible IMO) Should we also remove the `feature = gl` parts of the examples to simplify them until GL is reenabled? Co-authored-by: Joshua Groves <josh@joshgroves.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
language: rust
|
||||
cache: cargo
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
@@ -48,7 +48,7 @@ env_logger = "0.7"
|
||||
glsl-to-spirv = "0.1"
|
||||
log = "0.4"
|
||||
png = "0.15"
|
||||
winit = "0.20.0-alpha4"
|
||||
winit = "0.20.0-alpha6"
|
||||
rand = "0.7.2"
|
||||
zerocopy = "0.2"
|
||||
futures = "0.3"
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn run<E: Example>(title: &str) {
|
||||
log::info!("Initializing the window...");
|
||||
|
||||
#[cfg(not(feature = "gl"))]
|
||||
let (_window, hidpi_factor, size, surface) = {
|
||||
let (window, hidpi_factor, size, surface) = {
|
||||
let window = winit::window::Window::new(&event_loop).unwrap();
|
||||
window.set_title(title);
|
||||
let hidpi_factor = window.hidpi_factor();
|
||||
@@ -73,7 +73,7 @@ pub fn run<E: Example>(title: &str) {
|
||||
};
|
||||
|
||||
#[cfg(feature = "gl")]
|
||||
let (_window, instance, hidpi_factor, size, surface) = {
|
||||
let (window, instance, hidpi_factor, size, surface) = {
|
||||
let wb = winit::WindowBuilder::new();
|
||||
let cb = wgpu::glutin::ContextBuilder::new().with_vsync(true);
|
||||
let context = cb.build_windowed(wb, &event_loop).unwrap();
|
||||
@@ -132,6 +132,7 @@ pub fn run<E: Example>(title: &str) {
|
||||
ControlFlow::Poll
|
||||
};
|
||||
match event {
|
||||
event::Event::MainEventsCleared => window.request_redraw(),
|
||||
event::Event::WindowEvent {
|
||||
event: WindowEvent::Resized(size),
|
||||
..
|
||||
@@ -162,15 +163,15 @@ pub fn run<E: Example>(title: &str) {
|
||||
_ => {
|
||||
example.update(event);
|
||||
}
|
||||
},
|
||||
event::Event::EventsCleared => {
|
||||
}
|
||||
event::Event::RedrawRequested(_) => {
|
||||
let frame = swap_chain
|
||||
.get_next_texture()
|
||||
.expect("Timeout when acquiring next swap chain texture");
|
||||
let command_buf = example.render(&frame, &device);
|
||||
queue.submit(&[command_buf]);
|
||||
}
|
||||
_ => (),
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ fn main() {
|
||||
let event_loop = EventLoop::new();
|
||||
|
||||
#[cfg(not(feature = "gl"))]
|
||||
let (_window, size, surface) = {
|
||||
let (window, size, surface) = {
|
||||
let window = winit::window::Window::new(&event_loop).unwrap();
|
||||
let size = window.inner_size().to_physical(window.hidpi_factor());
|
||||
|
||||
@@ -17,7 +17,7 @@ fn main() {
|
||||
};
|
||||
|
||||
#[cfg(feature = "gl")]
|
||||
let (_window, instance, size, surface) = {
|
||||
let (window, instance, size, surface) = {
|
||||
let wb = winit::WindowBuilder::new();
|
||||
let cb = wgpu::glutin::ContextBuilder::new().with_vsync(true);
|
||||
let context = cb.build_windowed(wb, &event_loop).unwrap();
|
||||
@@ -113,28 +113,10 @@ fn main() {
|
||||
);
|
||||
|
||||
event_loop.run(move |event, _, control_flow| {
|
||||
*control_flow = if cfg!(feature = "metal-auto-capture") {
|
||||
ControlFlow::Exit
|
||||
} else {
|
||||
ControlFlow::Poll
|
||||
};
|
||||
*control_flow = ControlFlow::Poll;
|
||||
match event {
|
||||
event::Event::WindowEvent { event, .. } => match event {
|
||||
event::WindowEvent::KeyboardInput {
|
||||
input:
|
||||
event::KeyboardInput {
|
||||
virtual_keycode: Some(event::VirtualKeyCode::Escape),
|
||||
state: event::ElementState::Pressed,
|
||||
..
|
||||
},
|
||||
..
|
||||
}
|
||||
| event::WindowEvent::CloseRequested => {
|
||||
*control_flow = ControlFlow::Exit;
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
event::Event::EventsCleared => {
|
||||
event::Event::MainEventsCleared => window.request_redraw(),
|
||||
event::Event::RedrawRequested(_) => {
|
||||
let frame = swap_chain
|
||||
.get_next_texture()
|
||||
.expect("Timeout when acquiring next swap chain texture");
|
||||
@@ -158,7 +140,11 @@ fn main() {
|
||||
|
||||
queue.submit(&[encoder.finish()]);
|
||||
}
|
||||
_ => (),
|
||||
event::Event::WindowEvent {
|
||||
event: event::WindowEvent::CloseRequested,
|
||||
..
|
||||
} => *control_flow = ControlFlow::Exit,
|
||||
_ => {}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user