From f15a03e79bdb2d4cc51d0935134421471be173b2 Mon Sep 17 00:00:00 2001 From: Tatsuyuki Ishi Date: Sun, 13 Oct 2019 18:36:23 +0900 Subject: [PATCH] Consistently report screen dimensions in physical pixels --- amethyst_window/src/resources.rs | 4 ++-- amethyst_window/src/system.rs | 3 ++- docs/CHANGELOG.md | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/amethyst_window/src/resources.rs b/amethyst_window/src/resources.rs index 5fda5d1d16..4ac122ea64 100644 --- a/amethyst_window/src/resources.rs +++ b/amethyst_window/src/resources.rs @@ -3,9 +3,9 @@ use amethyst_core::math::Vector2; /// World resource that stores screen dimensions. #[derive(Debug, PartialEq, Clone)] pub struct ScreenDimensions { - /// Screen width in pixels (px). + /// Screen width in physical pixels (px). pub(crate) w: f64, - /// Screen height in pixels (px). + /// Screen height in physical pixels (px). pub(crate) h: f64, /// Width divided by height. aspect_ratio: f32, diff --git a/amethyst_window/src/system.rs b/amethyst_window/src/system.rs index ea759ae26c..73dc0a3f75 100644 --- a/amethyst_window/src/system.rs +++ b/amethyst_window/src/system.rs @@ -34,11 +34,12 @@ impl WindowSystem { /// Create a new `WindowSystem` wrapping the provided `Window` pub fn new(world: &mut World, window: Window) -> Self { + let hidpi = window.get_hidpi_factor(); let (width, height) = window .get_inner_size() .expect("Window closed during initialization!") + .to_physical(hidpi) .into(); - let hidpi = window.get_hidpi_factor(); world.insert(ScreenDimensions::new(width, height, hidpi)); world.insert(window); Self diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6e8432eba9..3b3caadda7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -22,6 +22,7 @@ The format is based on [Keep a Changelog][kc], and this project adheres to - amethyst_network completely rewritten to provide a new baseline with which to build. ([#1917]) - Cleaned up tiles example. Added rotation and translation tests, fixed raycast debug box. Added default zoom to PROJECT perspective projection since no one knew to zoom out. ([#1974]) +- ScreenDimensions now consistently reports window size in physical pixels. ([#1988]) ### Deprecated