diff --git a/imgui-examples/examples/support/mod.rs b/imgui-examples/examples/support/mod.rs index 6ee1986b6..011b8f794 100644 --- a/imgui-examples/examples/support/mod.rs +++ b/imgui-examples/examples/support/mod.rs @@ -129,14 +129,11 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ }); } - let size_pixels = gl_window.get_inner_size().unwrap(); + let size_points = gl_window.get_inner_size().unwrap(); let hdipi = gl_window.get_hidpi_factor(); - let size_points = ( - (size_pixels.width as f64 / hdipi) as u32, - (size_pixels.height as f64 / hdipi) as u32, - ); + let size_pixels = size_points.to_physical(hdipi); - let ui = imgui.frame(size_points, size_pixels.into(), delta_s); + let ui = imgui.frame(size_points.into(), size_pixels.into(), delta_s); if !run_ui(&ui) { break; } @@ -182,11 +179,7 @@ fn configure_keys(imgui: &mut ImGui) { } fn update_mouse(imgui: &mut ImGui, mouse_state: &mut MouseState) { - let scale = imgui.display_framebuffer_scale(); - imgui.set_mouse_pos( - mouse_state.pos.0 as f32 / scale.0, - mouse_state.pos.1 as f32 / scale.1, - ); + imgui.set_mouse_pos(mouse_state.pos.0 as f32, mouse_state.pos.1 as f32); imgui.set_mouse_down( &[ mouse_state.pressed.0, @@ -196,6 +189,6 @@ fn update_mouse(imgui: &mut ImGui, mouse_state: &mut MouseState) { false, ], ); - imgui.set_mouse_wheel(mouse_state.wheel / scale.1); + imgui.set_mouse_wheel(mouse_state.wheel); mouse_state.wheel = 0.0; } diff --git a/imgui-examples/examples/support_gfx/mod.rs b/imgui-examples/examples/support_gfx/mod.rs index 74c88f68f..ee1775c70 100644 --- a/imgui-examples/examples/support_gfx/mod.rs +++ b/imgui-examples/examples/support_gfx/mod.rs @@ -174,14 +174,11 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ }); } - let size_pixels = window.get_inner_size().unwrap(); + let size_points = window.get_inner_size().unwrap(); let hdipi = window.get_hidpi_factor(); - let size_points = ( - (size_pixels.width as f64 / hdipi) as u32, - (size_pixels.height as f64 / hdipi) as u32, - ); + let size_pixels = size_points.to_physical(hdipi); - let ui = imgui.frame(size_points, size_pixels.into(), delta_s); + let ui = imgui.frame(size_points.into(), size_pixels.into(), delta_s); let texture = ui.make_texture(im_str!("#STANDARD"), || gfx_load_texture(&mut factory)); ui.image(&texture, (100.0, 100.0)).build(); let texture = ui.replace_texture(im_str!("#CHANGE"), gfx_load_texture_change(&mut factory)); @@ -226,11 +223,7 @@ fn configure_keys(imgui: &mut ImGui) { } fn update_mouse(imgui: &mut ImGui, mouse_state: &mut MouseState) { - let scale = imgui.display_framebuffer_scale(); - imgui.set_mouse_pos( - mouse_state.pos.0 as f32 / scale.0, - mouse_state.pos.1 as f32 / scale.1, - ); + imgui.set_mouse_pos(mouse_state.pos.0 as f32, mouse_state.pos.1 as f32); imgui.set_mouse_down( &[ mouse_state.pressed.0, @@ -240,7 +233,7 @@ fn update_mouse(imgui: &mut ImGui, mouse_state: &mut MouseState) { false, ], ); - imgui.set_mouse_wheel(mouse_state.wheel / scale.1); + imgui.set_mouse_wheel(mouse_state.wheel); mouse_state.wheel = 0.0; }