Skip to content

Commit

Permalink
examples: Fix winit deprecation warnings
Browse files Browse the repository at this point in the history
Since the following pull request
rust-windowing/winit#319, `winit` has deprecated
`get_inner_size_points()` and `get_inner_size_pixels()`.

We replace the deprecated API by `get_inner_size()` and
`hidpi_factor()`. The size in points in computed from the returned
hidpi_factor.
  • Loading branch information
malikolivier committed Mar 15, 2018
1 parent bafe886 commit e86cd88
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions imgui-examples/examples/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
update_mouse(&mut imgui, &mut mouse_state);

let gl_window = display.gl_window();
let size_points = gl_window.get_inner_size_points().unwrap();
let size_pixels = gl_window.get_inner_size_pixels().unwrap();
let size_pixels = gl_window.get_inner_size().unwrap();
let hdipi = gl_window.hidpi_factor();
let size_points = (
(size_pixels.0 as f32 / hdipi) as u32,
(size_pixels.1 as f32 / hdipi) as u32,
);

let ui = imgui.frame(size_points, size_pixels, delta_s);
if !run_ui(&ui) {
Expand Down
8 changes: 6 additions & 2 deletions imgui-examples/examples/support_gfx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_

update_mouse(&mut imgui, &mut mouse_state);

let size_points = window.get_inner_size_points().unwrap();
let size_pixels = window.get_inner_size_pixels().unwrap();
let size_pixels = window.get_inner_size().unwrap();
let hdipi = window.hidpi_factor();
let size_points = (
(size_pixels.0 as f32 / hdipi) as u32,
(size_pixels.1 as f32 / hdipi) as u32,
);

let ui = imgui.frame(size_points, size_pixels, delta_s);
if !run_ui(&ui) {
Expand Down

0 comments on commit e86cd88

Please sign in to comment.