Skip to content

Commit

Permalink
Merge pull request #33 from CarlosEduardoL/main
Browse files Browse the repository at this point in the history
Fix "Could't get DPI" on VMs
  • Loading branch information
ArjunNair authored Oct 22, 2023
2 parents e4fc599 + 5052328 commit bae898e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ pub fn with_sdl2(
shader_ver: ShaderVersion,
scale: DpiScaling,
) -> (Painter, EguiStateHandler) {
let display_dpi = window
.subsystem()
.display_dpi(0)
.unwrap_or((96.0, 96.0, 96.0));
let scale = match scale {
DpiScaling::Default => 96.0 / window.subsystem().display_dpi(0).unwrap().0,
DpiScaling::Custom(custom) => {
(96.0 / window.subsystem().display_dpi(0).unwrap().0) * custom
}
DpiScaling::Default => 96.0 / display_dpi.0,
DpiScaling::Custom(custom) => (96.0 / display_dpi.0) * custom,
};
let painter = painter::Painter::new(window, scale, shader_ver);
EguiStateHandler::new(painter)
Expand Down

0 comments on commit bae898e

Please sign in to comment.