Skip to content

Commit 99db59c

Browse files
MScottMcBeemockersf
authored andcommitted
Have WindowPosition::Centered take scale_factor_override into account (#13949)
# Objective Fixes #8916 My game has a low resolution pixel art style, and I use `.with_scale_factor_override()` to make the window larger. `WindowPosition::Centered` doesn't work for me. ## Solution If `scale_factor_override` is set, use that over `monitor.scale_factor` ## Testing Tested on Windows 11 with an Nvidia GPU: ### Main ![image](https://github.com/bevyengine/bevy/assets/3324533/5f9ae90e-b65a-48d9-b601-117df8f08a28) ### This PR ![image](https://github.com/bevyengine/bevy/assets/3324533/cd860611-7b6a-4ae5-b690-28d9ba8ea6ad)
1 parent 9a4de9c commit 99db59c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

crates/bevy_winit/src/winit_windows.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,12 @@ pub fn winit_window_position(
379379
if let Some(monitor) = maybe_monitor {
380380
let screen_size = monitor.size();
381381

382-
// We use the monitors scale factor here since `WindowResolution.scale_factor` is
383-
// not yet populated when windows are created during plugin setup.
384-
let scale_factor = monitor.scale_factor();
382+
let scale_factor = match resolution.scale_factor_override() {
383+
Some(scale_factor_override) => scale_factor_override as f64,
384+
// We use the monitors scale factor here since `WindowResolution.scale_factor` is
385+
// not yet populated when windows are created during plugin setup.
386+
None => monitor.scale_factor(),
387+
};
385388

386389
// Logical to physical window size
387390
let (width, height): (u32, u32) =

0 commit comments

Comments
 (0)