Skip to content

Commit 246375f

Browse files
authored
treewide: bump dependencies (#60)
1 parent db8f6bb commit 246375f

8 files changed

Lines changed: 163 additions & 153 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: rust
22
rust:
33
# MSRV
4-
- 1.36.0
4+
- 1.40.0
55

66
# Stable release channel
77
- stable

Cargo.toml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,27 @@ travis-ci = { repository = "parasyte/pixels" }
2323
maintenance = { status = "actively-developed" }
2424

2525
[dependencies]
26-
thiserror = "1.0"
27-
wgpu = "0.4"
26+
thiserror = "1.0.15"
27+
wgpu = "0.5.0"
28+
futures = "0.3"
2829

2930
# These are only used by the examples, and enabled with features
3031
# See: https://github.com/rust-lang/cargo/issues/1982
31-
beryllium = { version = " 0.1", optional = true }
32-
byteorder = { version = "1.3", optional = true }
33-
env_logger = { version = "0.7", optional = true }
34-
getrandom = { version = "0.1", optional = true }
35-
gilrs = { version = "0.7", optional = true }
36-
line_drawing = { version = "0.8", optional = true }
37-
log = { version = "0.4", features = ["release_max_level_warn"], optional = true }
38-
randomize = { version = "3.0", optional = true }
32+
beryllium = { version = "0.2.1", features = [ "extern_crate_raw_window_handle" ], optional = true }
33+
byteorder = { version = "1.3.4", optional = true }
34+
env_logger = { version = "0.7.1", optional = true }
35+
getrandom = { version = "0.1.14", optional = true }
36+
gilrs = { version = "0.7.4", optional = true }
37+
line_drawing = { version = "0.8.0", optional = true }
38+
log = { version = "0.4.8", features = [ "release_max_level_warn" ], optional = true }
39+
randomize = { version = "3.0.1", optional = true }
3940
simple-invaders = { path = "simple-invaders", optional = true }
40-
winit = { version = "=0.20.0-alpha4", optional = true }
41-
winit_input_helper = { version = "=0.4.0-alpha4", optional = true }
41+
winit = { version = "0.22.0", optional = true }
42+
winit_input_helper = { version = "0.6.0", optional = true }
4243

4344
[dev-dependencies]
4445
pixels-mocks = { path = "pixels-mocks" }
45-
winit = "=0.20.0-alpha4"
46+
winit = "0.22.0"
4647

4748
[[example]]
4849
name = "conway"

examples/conway/main.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use log::debug;
55
use pixels::{Error, Pixels, SurfaceTexture};
66
use winit::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
7-
use winit::event::{Event, VirtualKeyCode, WindowEvent};
7+
use winit::event::{Event, VirtualKeyCode};
88
use winit::event_loop::{ControlFlow, EventLoop};
99
use winit_input_helper::WinitInputHelper;
1010

@@ -15,7 +15,7 @@ fn main() -> Result<(), Error> {
1515
env_logger::init();
1616
let event_loop = EventLoop::new();
1717
let mut input = WinitInputHelper::new();
18-
let (window, surface, mut p_width, mut p_height, mut hidpi_factor) =
18+
let (window, surface, p_width, p_height, mut hidpi_factor) =
1919
create_window("Conway's Game of Life", &event_loop);
2020

2121
let surface_texture = SurfaceTexture::new(p_width, p_height, surface);
@@ -28,13 +28,9 @@ fn main() -> Result<(), Error> {
2828

2929
event_loop.run(move |event, _, control_flow| {
3030
// The one and only event that winit_input_helper doesn't have for us...
31-
if let Event::WindowEvent {
32-
event: WindowEvent::RedrawRequested,
33-
..
34-
} = event
35-
{
31+
if let Event::RedrawRequested(_) = event {
3632
life.draw(pixels.get_frame());
37-
pixels.render();
33+
pixels.render().unwrap();
3834
}
3935

4036
// For everything else, for let winit_input_helper collect events to build its state.
@@ -100,15 +96,12 @@ fn main() -> Result<(), Error> {
10096
}
10197
}
10298
// Adjust high DPI factor
103-
if let Some(factor) = input.hidpi_changed() {
99+
if let Some(factor) = input.scale_factor_changed() {
104100
hidpi_factor = factor;
105101
}
106102
// Resize the window
107103
if let Some(size) = input.window_resized() {
108-
let size = size.to_physical(hidpi_factor);
109-
p_width = size.width.round() as u32;
110-
p_height = size.height.round() as u32;
111-
pixels.resize(p_width, p_height);
104+
pixels.resize(size.width, size.height);
112105
}
113106
if !paused || input.key_pressed(VirtualKeyCode::Space) {
114107
life.update();
@@ -138,19 +131,23 @@ fn create_window(
138131
.with_title(title)
139132
.build(&event_loop)
140133
.unwrap();
141-
let hidpi_factor = window.hidpi_factor();
134+
let hidpi_factor = window.scale_factor();
142135

143136
// Get dimensions
144137
let width = SCREEN_WIDTH as f64;
145138
let height = SCREEN_HEIGHT as f64;
146139
let (monitor_width, monitor_height) = {
147140
let size = window.current_monitor().size();
148-
(size.width / hidpi_factor, size.height / hidpi_factor)
141+
(
142+
size.width as f64 / hidpi_factor,
143+
size.height as f64 / hidpi_factor,
144+
)
149145
};
150146
let scale = (monitor_height / height * 2.0 / 3.0).round();
151147

152148
// Resize, center, and display the window
153-
let min_size = PhysicalSize::new(width, height).to_logical(hidpi_factor);
149+
let min_size: winit::dpi::LogicalSize<f64> =
150+
PhysicalSize::new(width, height).to_logical(hidpi_factor);
154151
let default_size = LogicalSize::new(width * scale, height * scale);
155152
let center = LogicalPosition::new(
156153
(monitor_width - width * scale) / 2.0,
@@ -162,7 +159,7 @@ fn create_window(
162159
window.set_visible(true);
163160

164161
let surface = pixels::wgpu::Surface::create(&window);
165-
let size = default_size.to_physical(hidpi_factor);
162+
let size = default_size.to_physical::<f64>(hidpi_factor);
166163

167164
(
168165
window,
@@ -302,14 +299,14 @@ impl ConwayGrid {
302299
} else {
303300
(y - 1, y + 1)
304301
};
305-
(self.cells[xm1 + ym1 * self.width].alive as usize
302+
self.cells[xm1 + ym1 * self.width].alive as usize
306303
+ self.cells[x + ym1 * self.width].alive as usize
307304
+ self.cells[xp1 + ym1 * self.width].alive as usize
308305
+ self.cells[xm1 + y * self.width].alive as usize
309306
+ self.cells[xp1 + y * self.width].alive as usize
310307
+ self.cells[xm1 + yp1 * self.width].alive as usize
311308
+ self.cells[x + yp1 * self.width].alive as usize
312-
+ self.cells[xp1 + yp1 * self.width].alive as usize)
309+
+ self.cells[xp1 + yp1 * self.width].alive as usize
313310
}
314311

315312
fn update(&mut self) {

examples/invaders/main.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use log::debug;
99
use pixels::{Error, Pixels, SurfaceTexture};
1010
use simple_invaders::{Controls, Direction, World, SCREEN_HEIGHT, SCREEN_WIDTH};
1111
use winit::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
12-
use winit::event::{Event, VirtualKeyCode, WindowEvent};
12+
use winit::event::{Event, VirtualKeyCode};
1313
use winit::event_loop::{ControlFlow, EventLoop};
1414
use winit_input_helper::WinitInputHelper;
1515

@@ -35,13 +35,9 @@ fn main() -> Result<(), Error> {
3535

3636
event_loop.run(move |event, _, control_flow| {
3737
// The one and only event that winit_input_helper doesn't have for us...
38-
if let Event::WindowEvent {
39-
event: WindowEvent::RedrawRequested,
40-
..
41-
} = event
42-
{
38+
if let Event::RedrawRequested(_) = event {
4339
invaders.draw(pixels.get_frame());
44-
pixels.render();
40+
pixels.render().unwrap();
4541
}
4642

4743
// Pump the gilrs event loop and find an active gamepad
@@ -95,17 +91,13 @@ fn main() -> Result<(), Error> {
9591
};
9692

9793
// Adjust high DPI factor
98-
if let Some(factor) = input.hidpi_changed() {
94+
if let Some(factor) = input.scale_factor_changed() {
9995
hidpi_factor = factor;
10096
}
10197

10298
// Resize the window
10399
if let Some(size) = input.window_resized() {
104-
let size = size.to_physical(hidpi_factor);
105-
let width = size.width.round() as u32;
106-
let height = size.height.round() as u32;
107-
108-
pixels.resize(width, height);
100+
pixels.resize(size.width, size.height);
109101
}
110102

111103
// Get a new delta time.
@@ -138,19 +130,22 @@ fn create_window(
138130
.with_title(title)
139131
.build(&event_loop)
140132
.unwrap();
141-
let hidpi_factor = window.hidpi_factor();
133+
let hidpi_factor = window.scale_factor();
142134

143135
// Get dimensions
144136
let width = SCREEN_WIDTH as f64;
145137
let height = SCREEN_HEIGHT as f64;
146138
let (monitor_width, monitor_height) = {
147139
let size = window.current_monitor().size();
148-
(size.width / hidpi_factor, size.height / hidpi_factor)
140+
(
141+
size.width as f64 / hidpi_factor,
142+
size.height as f64 / hidpi_factor,
143+
)
149144
};
150145
let scale = (monitor_height / height * 2.0 / 3.0).round();
151146

152147
// Resize, center, and display the window
153-
let min_size = PhysicalSize::new(width, height).to_logical(hidpi_factor);
148+
let min_size = PhysicalSize::new(width, height).to_logical::<f64>(hidpi_factor);
154149
let default_size = LogicalSize::new(width * scale, height * scale);
155150
let center = LogicalPosition::new(
156151
(monitor_width - width * scale) / 2.0,
@@ -162,7 +157,7 @@ fn create_window(
162157
window.set_visible(true);
163158

164159
let surface = pixels::wgpu::Surface::create(&window);
165-
let size = default_size.to_physical(hidpi_factor);
160+
let size = default_size.to_physical::<f64>(hidpi_factor);
166161

167162
(
168163
window,

examples/minimal-sdl2/main.rs

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,43 @@ struct World {
1717
velocity_y: i16,
1818
}
1919

20-
fn main() -> Result<(), String> {
20+
fn main() -> Result<(), Box<dyn std::error::Error>> {
2121
env_logger::init();
22-
let sdl = beryllium::init()?;
23-
let window = sdl.create_window(
24-
"Hello Pixels",
25-
WINDOW_POSITION_CENTERED,
26-
WINDOW_POSITION_CENTERED,
27-
WIDTH as i32,
28-
HEIGHT as i32,
29-
WindowFlags::default(),
30-
)?;
31-
window.set_minimum_size(WIDTH as i32, HEIGHT as i32);
32-
window.set_resizable(true);
22+
let sdl = SDL::init(InitFlags::default())?;
23+
let window =
24+
sdl.create_raw_window("Hello Pixels", WindowPosition::Centered, WIDTH, HEIGHT, 0)?;
3325

3426
let mut pixels = {
3527
let surface = Surface::create(&window);
3628
let surface_texture = SurfaceTexture::new(WIDTH, HEIGHT, surface);
37-
Pixels::new(WIDTH, HEIGHT, surface_texture).map_err(|e| format!("{:?}", e))?
29+
Pixels::new(WIDTH, HEIGHT, surface_texture)?
3830
};
3931
let mut world = World::new();
4032

4133
'game_loop: loop {
42-
while let Some(event) = sdl.poll_event() {
43-
match event {
44-
// Close events
45-
Event::Quit { .. } => break 'game_loop,
46-
Event::Keyboard {
47-
key_info:
48-
KeyInfo {
49-
keycode: Some(key), ..
50-
},
51-
..
52-
} if key == Keycode::Escape => break 'game_loop,
53-
54-
// Resize the window
55-
Event::WindowSizeChanged { width, height, .. } => {
56-
pixels.resize(width as u32, height as u32)
57-
}
58-
59-
_ => (),
60-
}
34+
match sdl.poll_events().and_then(Result::ok) {
35+
// Close events
36+
Some(Event::Quit { .. }) => break 'game_loop,
37+
Some(Event::Keyboard(KeyboardEvent {
38+
key: KeyInfo { keycode: key, .. },
39+
..
40+
})) if key == Keycode::ESCAPE => break 'game_loop,
41+
42+
// Resize the window
43+
Some(Event::Window(WindowEvent {
44+
event: WindowEventEnum::Resized { w, h },
45+
..
46+
})) => pixels.resize(w as u32, h as u32),
47+
48+
_ => (),
6149
}
6250

6351
// Update internal state
6452
world.update();
6553

6654
// Draw the current frame
6755
world.draw(pixels.get_frame());
68-
pixels.render();
56+
pixels.render()?;
6957
}
7058

7159
Ok(())

examples/minimal-winit/main.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use pixels::{wgpu::Surface, Error, Pixels, SurfaceTexture};
55
use winit::dpi::LogicalSize;
6-
use winit::event::{Event, VirtualKeyCode, WindowEvent};
6+
use winit::event::{Event, VirtualKeyCode};
77
use winit::event_loop::{ControlFlow, EventLoop};
88
use winit::window::WindowBuilder;
99
use winit_input_helper::WinitInputHelper;
@@ -33,7 +33,7 @@ fn main() -> Result<(), Error> {
3333
.build(&event_loop)
3434
.unwrap()
3535
};
36-
let mut hidpi_factor = window.hidpi_factor();
36+
let mut hidpi_factor = window.scale_factor();
3737

3838
let mut pixels = {
3939
let surface = Surface::create(&window);
@@ -44,13 +44,9 @@ fn main() -> Result<(), Error> {
4444

4545
event_loop.run(move |event, _, control_flow| {
4646
// Draw the current frame
47-
if let Event::WindowEvent {
48-
event: WindowEvent::RedrawRequested,
49-
..
50-
} = event
51-
{
47+
if let Event::RedrawRequested(_) = event {
5248
world.draw(pixels.get_frame());
53-
pixels.render();
49+
pixels.render().unwrap();
5450
}
5551

5652
// Handle input events
@@ -62,17 +58,13 @@ fn main() -> Result<(), Error> {
6258
}
6359

6460
// Adjust high DPI factor
65-
if let Some(factor) = input.hidpi_changed() {
61+
if let Some(factor) = input.scale_factor_changed() {
6662
hidpi_factor = factor;
6763
}
6864

6965
// Resize the window
7066
if let Some(size) = input.window_resized() {
71-
let size = size.to_physical(hidpi_factor);
72-
let width = size.width.round() as u32;
73-
let height = size.height.round() as u32;
74-
75-
pixels.resize(width, height);
67+
pixels.resize(size.width, size.height);
7668
}
7769

7870
// Update internal state and request a redraw

0 commit comments

Comments
 (0)