Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
1988: Consistently report screen dimensions in physical pixels r=Xaeroxe,azriel91 a=ishitatsuyuki

## Description

Fix amethyst#1943

Docs and changelog updated for clarity.

## PR Checklist

By placing an x in the boxes I certify that I have:

- [X] Added a changelog entry if this will impact users, or modified more than 5 lines of Rust that wasn't a doc comment.
- [X] Acknowledged that by making this pull request I release this code under an MIT/Apache 2.0 dual licensing scheme.

Co-authored-by: Tatsuyuki Ishi <[email protected]>
  • Loading branch information
bors[bot] and ishitatsuyuki authored Oct 15, 2019
2 parents 03cac16 + 902ad54 commit f6a1bae
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions amethyst_window/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion amethyst_window/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
- `AmethystApplication::with_fn` constraint relaxed from `Fn` to `FnOnce`. ([#1983])
- ScreenDimensions now consistently reports window size in physical pixels. ([#1988])

### Deprecated

Expand Down

0 comments on commit f6a1bae

Please sign in to comment.