Skip to content

Commit ea1992f

Browse files
committed
Fixed screenshot and render to texture when using Windows scaling
1 parent f1a650c commit ea1992f

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/camera.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -585,26 +585,32 @@ fn update_camera(
585585
info!("Window resized - resizing all textures");
586586

587587
// TODO: Do we really want to resize these images every time?
588+
let image_width = physical_view_width as f32;// / window.scale_factor() as f32;
589+
let image_height = (window.physical_height() - top_panel_height as u32) as f32;// / window.scale_factor() as f32;
590+
588591
images
589592
.get_mut(&camera_setup.target.as_ref().unwrap())
590593
.unwrap()
591594
.resize(Extent3d {
592-
width: physical_view_width,
593-
height: window.physical_height() - top_panel_height as u32,
595+
width: image_width as u32,
596+
height: image_height as u32,
594597
..default()
595598
});
596599
images
597600
.get_mut(&camera_setup.cpu_target.as_ref().unwrap())
598601
.unwrap()
599602
.resize(Extent3d {
600-
width: physical_view_width,
601-
height: window.physical_height() - top_panel_height as u32,
603+
width: image_width as u32,
604+
height: image_height as u32,
602605
..default()
603606
});
604607

605608
if let Ok(mut view_texture_transform) = view_texture.get_single_mut() {
606-
view_texture_transform.translation.x = -panel_width / 2.0;
607-
view_texture_transform.translation.y = top_panel_height / 2.0;
609+
view_texture_transform.translation.x = -panel_width / 2.0 / window.scale_factor() as f32;
610+
view_texture_transform.translation.y = top_panel_height / 2.0 / window.scale_factor() as f32;
611+
612+
view_texture_transform.scale.x = 1.0 / window.scale_factor() as f32;
613+
view_texture_transform.scale.y = 1.0 / window.scale_factor() as f32;
608614
}
609615

610616
// println!("{:?}", window);

0 commit comments

Comments
 (0)