Skip to content

Commit

Permalink
Fixes bevyengine#12000: When Viewport is set to Camera and switched t…
Browse files Browse the repository at this point in the history
…o SizedFullscreen, panic may occur

When ajusting to SizedFullscreen, the window size might be lower than the viewport size, causing the render
target to be smaller than the Viewport. The fix consist of matching the viewport size with the render target
size when this is lower, avoiding panic. These lower values may vary depending on the device.
  • Loading branch information
LuisFigueiredo73 committed Apr 1, 2024
1 parent 6840f95 commit d7de86f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/bevy_render/src/camera/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,17 @@ pub fn camera_system<T: CameraProjection + Component>(
}
}
}
if let Some(viewport) = &mut camera.viewport {
let target_info = &new_computed_target_info;
if let Some(target) = target_info {
if viewport.physical_size.x > target.physical_size.x {
viewport.physical_size.x = target.physical_size.x;
}
if viewport.physical_size.y > target.physical_size.y {
viewport.physical_size.y = target.physical_size.y;
}
}
}
camera.computed.target_info = new_computed_target_info;
if let Some(size) = camera.logical_viewport_size() {
camera_projection.update(size.x, size.y);
Expand Down

0 comments on commit d7de86f

Please sign in to comment.