Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

Commit

Permalink
Fixed wrong reported screen dimensions, and initial screen dimensions…
Browse files Browse the repository at this point in the history
… (DisplayConfig).
  • Loading branch information
AnneKitsune committed Dec 12, 2018
1 parent 45fe5d0 commit 1953845
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions amethyst_renderer/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,18 @@ impl RendererBuilder {
wb = wb.with_fullscreen(Some(self.events.get_primary_monitor()));
}

let hidpi = self.events.get_primary_monitor().get_hidpi_factor();

if let Some(dimensions) = self.config.dimensions {
wb = wb.with_dimensions(dimensions.into());
wb = wb.with_dimensions(LogicalSize::from_physical(dimensions, hidpi));
}

if let Some(dimensions) = self.config.min_dimensions {
wb = wb.with_min_dimensions(dimensions.into());
wb = wb.with_min_dimensions(LogicalSize::from_physical(dimensions, hidpi));
}

if let Some(dimensions) = self.config.max_dimensions {
wb = wb.with_max_dimensions(dimensions.into());
wb = wb.with_max_dimensions(LogicalSize::from_physical(dimensions, hidpi));
}

self.winit_builder = wb;
Expand Down
6 changes: 4 additions & 2 deletions amethyst_renderer/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ where
screen_dimensions.dirty = false;
}

let hidpi = self.renderer.window().get_hidpi_factor();

if let Some(size) = self.renderer.window().get_inner_size() {
let (window_width, window_height): (f64, f64) = size.into();
let (window_width, window_height): (f64, f64) = size.to_physical(hidpi).into();

// Send window size changes to the resource
if (window_width, window_height) != (width, height) {
Expand All @@ -139,7 +141,7 @@ where
screen_dimensions.dirty = false;
}
}
screen_dimensions.update_hidpi_factor(self.renderer.window().get_hidpi_factor());
screen_dimensions.update_hidpi_factor(hidpi);
}

fn render(&mut self, (mut event_handler, data): RenderData<'_, P>) {
Expand Down

0 comments on commit 1953845

Please sign in to comment.