diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26a3aa5..8296d4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: rust: - stable - beta - - 1.41.0 + - 1.43.0 steps: - name: Checkout sources uses: actions/checkout@v2 @@ -40,7 +40,7 @@ jobs: rust: - stable - beta - - 1.41.0 + - 1.43.0 steps: - name: Checkout sources uses: actions/checkout@v2 diff --git a/Cargo.toml b/Cargo.toml index 141a1dd..7abafaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,12 +22,12 @@ include = [ pollster = "0.2" raw-window-handle = "0.3" thiserror = "1.0" -ultraviolet = "0.4" +ultraviolet = "0.7" wgpu = "0.6" [dev-dependencies] pixels-mocks = { path = "internals/pixels-mocks" } -winit = "0.22" +winit = "0.24" [workspace] members = [ diff --git a/examples/conway/Cargo.toml b/examples/conway/Cargo.toml index a0d8bbf..5597b84 100644 --- a/examples/conway/Cargo.toml +++ b/examples/conway/Cargo.toml @@ -10,12 +10,12 @@ optimize = ["log/release_max_level_warn"] default = ["optimize"] [dependencies] -byteorder = "1.3.4" -env_logger = "0.7.1" -getrandom = "0.1.14" -line_drawing = "0.8.0" -log = "0.4.8" +byteorder = "1.3" +env_logger = "0.8" +getrandom = "0.2" +line_drawing = "0.8" +log = "0.4" pixels = { path = "../.." } -randomize = "3.0.1" -winit = "0.22.0" -winit_input_helper = "0.6.0" +randomize = "3.0" +winit = "0.24" +winit_input_helper = "0.9" diff --git a/examples/conway/src/main.rs b/examples/conway/src/main.rs index 5b05600..ab4b366 100644 --- a/examples/conway/src/main.rs +++ b/examples/conway/src/main.rs @@ -42,7 +42,7 @@ fn main() -> Result<(), Error> { // For everything else, for let winit_input_helper collect events to build its state. // It returns `true` when it is time to update our game state and request a redraw. - if input.update(event) { + if input.update(&event) { // Close events if input.key_pressed(VirtualKeyCode::Escape) || input.quit() { *control_flow = ControlFlow::Exit; @@ -150,13 +150,14 @@ fn create_window( let width = SCREEN_WIDTH as f64; let height = SCREEN_HEIGHT as f64; let (monitor_width, monitor_height) = { - let size = window.current_monitor().size(); - ( - size.width as f64 / hidpi_factor, - size.height as f64 / hidpi_factor, - ) + if let Some(monitor) = window.current_monitor() { + let size = monitor.size().to_logical(hidpi_factor); + (size.width, size.height) + } else { + (width, height) + } }; - let scale = (monitor_height / height * 2.0 / 3.0).round(); + let scale = (monitor_height / height * 2.0 / 3.0).round().max(1.0); // Resize, center, and display the window let min_size: winit::dpi::LogicalSize = diff --git a/examples/custom-shader/Cargo.toml b/examples/custom-shader/Cargo.toml index ee410b2..e7bd697 100644 --- a/examples/custom-shader/Cargo.toml +++ b/examples/custom-shader/Cargo.toml @@ -10,8 +10,8 @@ optimize = ["log/release_max_level_warn"] default = ["optimize"] [dependencies] -env_logger = "0.7.1" -log = "0.4.8" +env_logger = "0.8" +log = "0.4" pixels = { path = "../.." } -winit = "0.22.0" -winit_input_helper = "0.6.0" +winit = "0.24" +winit_input_helper = "0.9" diff --git a/examples/custom-shader/src/main.rs b/examples/custom-shader/src/main.rs index 02fee0a..aa745d3 100644 --- a/examples/custom-shader/src/main.rs +++ b/examples/custom-shader/src/main.rs @@ -72,7 +72,7 @@ fn main() -> Result<(), Error> { } // Handle input events - if input.update(event) { + if input.update(&event) { // Close events if input.key_pressed(VirtualKeyCode::Escape) || input.quit() { *control_flow = ControlFlow::Exit; diff --git a/examples/imgui-winit/Cargo.toml b/examples/imgui-winit/Cargo.toml index ce4a02b..3368689 100644 --- a/examples/imgui-winit/Cargo.toml +++ b/examples/imgui-winit/Cargo.toml @@ -10,11 +10,11 @@ optimize = ["log/release_max_level_warn"] default = ["optimize"] [dependencies] -env_logger = "0.7" -imgui = "0.4" -imgui-wgpu = "0.9" -imgui-winit-support = { version = "0.4", default-features = false, features = ["winit-22"] } +env_logger = "0.8" +imgui = "0.6" +imgui-wgpu = "0.12" +imgui-winit-support = "0.6" log = "0.4" pixels = { path = "../.." } -winit = "0.22" -winit_input_helper = "0.6" +winit = "0.24" +winit_input_helper = "0.9" diff --git a/examples/imgui-winit/src/gui.rs b/examples/imgui-winit/src/gui.rs index cdedb35..2cdc768 100644 --- a/examples/imgui-winit/src/gui.rs +++ b/examples/imgui-winit/src/gui.rs @@ -22,7 +22,7 @@ impl Gui { let mut platform = imgui_winit_support::WinitPlatform::init(&mut imgui); platform.attach_window( imgui.io_mut(), - &window, + window, imgui_winit_support::HiDpiMode::Default, ); @@ -51,7 +51,11 @@ impl Gui { let device = pixels.device(); let queue = pixels.queue(); let texture_format = wgpu::TextureFormat::Bgra8UnormSrgb; - let renderer = imgui_wgpu::Renderer::new(&mut imgui, &device, &queue, texture_format); + let config = imgui_wgpu::RendererConfig { + texture_format, + ..Default::default() + }; + let renderer = imgui_wgpu::Renderer::new(&mut imgui, &device, &queue, config); // Return GUI context Self { @@ -70,9 +74,10 @@ impl Gui { window: &winit::window::Window, ) -> Result<(), winit::error::ExternalError> { // Prepare Dear ImGui - let io = self.imgui.io_mut(); - self.last_frame = io.update_delta_time(self.last_frame); - self.platform.prepare_frame(io, window) + let now = Instant::now(); + self.imgui.io_mut().update_delta_time(now - self.last_frame); + self.last_frame = now; + self.platform.prepare_frame(self.imgui.io_mut(), window) } /// Render Dear ImGui. diff --git a/examples/imgui-winit/src/main.rs b/examples/imgui-winit/src/main.rs index e6032bf..d74ab4f 100644 --- a/examples/imgui-winit/src/main.rs +++ b/examples/imgui-winit/src/main.rs @@ -79,7 +79,7 @@ fn main() -> Result<(), Error> { // Handle input events gui.handle_event(&window, &event); - if input.update(event) { + if input.update(&event) { // Close events if input.key_pressed(VirtualKeyCode::Escape) || input.quit() { *control_flow = ControlFlow::Exit; @@ -124,7 +124,7 @@ impl World { /// Draw the `World` state to the frame buffer. /// - /// Assumes the default texture format: [`wgpu::TextureFormat::Rgba8UnormSrgb`] + /// Assumes the default texture format: `wgpu::TextureFormat::Rgba8UnormSrgb` fn draw(&self, frame: &mut [u8]) { for (i, pixel) in frame.chunks_exact_mut(4).enumerate() { let x = (i % WIDTH as usize) as i16; diff --git a/examples/invaders/Cargo.toml b/examples/invaders/Cargo.toml index 029cae1..e3f7a04 100644 --- a/examples/invaders/Cargo.toml +++ b/examples/invaders/Cargo.toml @@ -10,13 +10,13 @@ optimize = ["log/release_max_level_warn"] default = ["optimize"] [dependencies] -byteorder = "1.3.4" -env_logger = "0.7.1" -getrandom = "0.1.14" -gilrs = "0.7.4" -log = "0.4.8" +byteorder = "1.3" +env_logger = "0.8" +getrandom = "0.2" +gilrs = "0.8" +log = "0.4" pixels = { path = "../.." } -randomize = "3.0.1" +randomize = "3.0" simple-invaders = { path = "simple-invaders" } -winit = "0.22.0" -winit_input_helper = "0.6.0" +winit = "0.24" +winit_input_helper = "0.9" diff --git a/examples/invaders/simple-invaders/Cargo.toml b/examples/invaders/simple-invaders/Cargo.toml index 0b3c63c..26b0404 100644 --- a/examples/invaders/simple-invaders/Cargo.toml +++ b/examples/invaders/simple-invaders/Cargo.toml @@ -11,4 +11,4 @@ randomize = "3.0" [dev-dependencies] byteorder = "1.3" -getrandom = "0.1" +getrandom = "0.2" diff --git a/examples/invaders/src/main.rs b/examples/invaders/src/main.rs index 6225461..263c252 100644 --- a/examples/invaders/src/main.rs +++ b/examples/invaders/src/main.rs @@ -60,7 +60,7 @@ fn main() -> Result<(), Error> { // For everything else, for let winit_input_helper collect events to build its state. // It returns `true` when it is time to update our game state and request a redraw. - if input.update(event) { + if input.update(&event) { // Close events if input.key_pressed(VirtualKeyCode::Escape) || input.quit() { *control_flow = ControlFlow::Exit; @@ -142,13 +142,14 @@ fn create_window( let width = SCREEN_WIDTH as f64; let height = SCREEN_HEIGHT as f64; let (monitor_width, monitor_height) = { - let size = window.current_monitor().size(); - ( - size.width as f64 / hidpi_factor, - size.height as f64 / hidpi_factor, - ) + if let Some(monitor) = window.current_monitor() { + let size = monitor.size().to_logical(hidpi_factor); + (size.width, size.height) + } else { + (width, height) + } }; - let scale = (monitor_height / height * 2.0 / 3.0).round(); + let scale = (monitor_height / height * 2.0 / 3.0).round().max(1.0); // Resize, center, and display the window let min_size = PhysicalSize::new(width, height).to_logical::(hidpi_factor); diff --git a/examples/minimal-sdl2/src/main.rs b/examples/minimal-sdl2/src/main.rs index 3556966..f244dd6 100644 --- a/examples/minimal-sdl2/src/main.rs +++ b/examples/minimal-sdl2/src/main.rs @@ -86,7 +86,7 @@ impl World { /// Draw the `World` state to the frame buffer. /// - /// Assumes the default texture format: [`wgpu::TextureFormat::Rgba8UnormSrgb`] + /// Assumes the default texture format: `wgpu::TextureFormat::Rgba8UnormSrgb` fn draw(&self, frame: &mut [u8]) { for (i, pixel) in frame.chunks_exact_mut(4).enumerate() { let x = (i % WIDTH as usize) as i16; diff --git a/examples/minimal-winit/Cargo.toml b/examples/minimal-winit/Cargo.toml index 7acbc4e..a15dba4 100644 --- a/examples/minimal-winit/Cargo.toml +++ b/examples/minimal-winit/Cargo.toml @@ -10,8 +10,8 @@ optimize = ["log/release_max_level_warn"] default = ["optimize"] [dependencies] -env_logger = "0.7.1" -log = "0.4.8" +env_logger = "0.7" +log = "0.4" pixels = { path = "../.." } -winit = "0.22.0" -winit_input_helper = "0.6.0" +winit = "0.24" +winit_input_helper = "0.9" diff --git a/examples/minimal-winit/src/main.rs b/examples/minimal-winit/src/main.rs index fcaeff7..799ba30 100644 --- a/examples/minimal-winit/src/main.rs +++ b/examples/minimal-winit/src/main.rs @@ -57,7 +57,7 @@ fn main() -> Result<(), Error> { } // Handle input events - if input.update(event) { + if input.update(&event) { // Close events if input.key_pressed(VirtualKeyCode::Escape) || input.quit() { *control_flow = ControlFlow::Exit; @@ -102,7 +102,7 @@ impl World { /// Draw the `World` state to the frame buffer. /// - /// Assumes the default texture format: [`wgpu::TextureFormat::Rgba8UnormSrgb`] + /// Assumes the default texture format: `wgpu::TextureFormat::Rgba8UnormSrgb` fn draw(&self, frame: &mut [u8]) { for (i, pixel) in frame.chunks_exact_mut(4).enumerate() { let x = (i % WIDTH as usize) as i16; diff --git a/examples/raqote-winit/Cargo.toml b/examples/raqote-winit/Cargo.toml index 1b8f4d4..359d1d1 100644 --- a/examples/raqote-winit/Cargo.toml +++ b/examples/raqote-winit/Cargo.toml @@ -10,10 +10,10 @@ optimize = ["log/release_max_level_warn"] default = ["optimize"] [dependencies] -env_logger = "0.7" -euclid = "0.20" +env_logger = "0.8" +euclid = "0.22" log = "0.4" pixels = { path = "../.." } -raqote = { version = "0.8", default-features = false } -winit = "0.22" -winit_input_helper = "0.6" +raqote = { git = "https://github.com/jrmuizel/raqote.git", rev = "74f0afa2be54561c1a9928e885ab95e8a4c5322d", default-features = false } +winit = "0.24" +winit_input_helper = "0.9" diff --git a/examples/raqote-winit/src/main.rs b/examples/raqote-winit/src/main.rs index 20858af..298697e 100644 --- a/examples/raqote-winit/src/main.rs +++ b/examples/raqote-winit/src/main.rs @@ -67,7 +67,7 @@ fn main() -> Result<(), Error> { } // Handle input events - if input.update(event) { + if input.update(&event) { // Close events if input.key_pressed(VirtualKeyCode::Escape) || input.quit() { *control_flow = ControlFlow::Exit; diff --git a/examples/raqote-winit/src/shapes.rs b/examples/raqote-winit/src/shapes.rs index c0dbd1a..eb56a83 100644 --- a/examples/raqote-winit/src/shapes.rs +++ b/examples/raqote-winit/src/shapes.rs @@ -55,9 +55,14 @@ impl Shapes { a: 0xff, }); - self.t1 = self.t1.post_translate(Vector2D::new(-self.cx, -self.cy)); - self.t1 = self.t1.post_rotate(Angle { radians: delta }); - self.t1 = self.t1.post_translate(Vector2D::new(self.cx, self.cy)); + let translate = Vector2D::new(-self.cx, -self.cy).to_transform(); + let inv_translate = translate + .inverse() + .unwrap_or_else(|| Vector2D::new(self.cx, self.cy).to_transform()); + + self.t1 = self.t1.then(&translate); + self.t1 = self.t1.then_rotate(Angle::radians(delta)); + self.t1 = self.t1.then(&inv_translate); self.dt.set_transform(&self.t1); let mut pb = PathBuilder::new(); @@ -91,9 +96,9 @@ impl Shapes { ); self.dt.fill(&path, &gradient, &DrawOptions::new()); - self.t2 = self.t2.post_translate(Vector2D::new(-self.cx, -self.cy)); - self.t2 = self.t2.post_rotate(Angle { radians: -delta }); - self.t2 = self.t2.post_translate(Vector2D::new(self.cx, self.cy)); + self.t2 = self.t2.then(&translate); + self.t2 = self.t2.then_rotate(Angle::radians(-delta)); + self.t2 = self.t2.then(&inv_translate); self.dt.set_transform(&self.t2); let mut pb = PathBuilder::new();