Skip to content

Commit

Permalink
Fixed screenshot and render to texture when using Windows scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanRace committed Nov 18, 2022
1 parent f1a650c commit ea1992f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,26 +585,32 @@ fn update_camera(
info!("Window resized - resizing all textures");

// TODO: Do we really want to resize these images every time?
let image_width = physical_view_width as f32;// / window.scale_factor() as f32;
let image_height = (window.physical_height() - top_panel_height as u32) as f32;// / window.scale_factor() as f32;

images
.get_mut(&camera_setup.target.as_ref().unwrap())
.unwrap()
.resize(Extent3d {
width: physical_view_width,
height: window.physical_height() - top_panel_height as u32,
width: image_width as u32,
height: image_height as u32,
..default()
});
images
.get_mut(&camera_setup.cpu_target.as_ref().unwrap())
.unwrap()
.resize(Extent3d {
width: physical_view_width,
height: window.physical_height() - top_panel_height as u32,
width: image_width as u32,
height: image_height as u32,
..default()
});

if let Ok(mut view_texture_transform) = view_texture.get_single_mut() {
view_texture_transform.translation.x = -panel_width / 2.0;
view_texture_transform.translation.y = top_panel_height / 2.0;
view_texture_transform.translation.x = -panel_width / 2.0 / window.scale_factor() as f32;
view_texture_transform.translation.y = top_panel_height / 2.0 / window.scale_factor() as f32;

view_texture_transform.scale.x = 1.0 / window.scale_factor() as f32;
view_texture_transform.scale.y = 1.0 / window.scale_factor() as f32;
}

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

0 comments on commit ea1992f

Please sign in to comment.