Skip to content

Commit

Permalink
fix coordinate conversion for hidpi displays
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhart committed Nov 28, 2017
1 parent a2b8e1f commit efc36eb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions hate/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ fn get_win_size(window: &glutin::Window) -> Size<i32> {
}

fn window_to_screen(context: &Context, x: f32, y: f32) -> Point {
let dpi = context.window.hidpi_factor();
let w = context.win_size.w as f32;
let h = context.win_size.h as f32;
let aspect_ratio = w / h;
Point(Vector2 {
x: (2.0 * x / w - 1.0) * aspect_ratio,
y: 1.0 - 2.0 * y / h,
x: (2.0 * (x/dpi) / w - 1.0) * aspect_ratio,
y: 1.0 - 2.0 * (y/dpi) / h,
})
}

Expand Down

0 comments on commit efc36eb

Please sign in to comment.