diff options
author | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
---|---|---|
committer | tcmal <me@aria.rip> | 2024-08-25 17:44:23 +0100 |
commit | ccf0074b08ce835cf22e7d46153d1cb3f3d06d32 (patch) | |
tree | cce0a39b4d1e3f272f071d5b9f2de9a403d396b4 /stockton-render/src/draw | |
parent | 6fd563b20772ad0ad279f6461179978766a77948 (diff) |
fix(render): get aspect ratio from renderer
Diffstat (limited to 'stockton-render/src/draw')
-rw-r--r-- | stockton-render/src/draw/camera.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/stockton-render/src/draw/camera.rs b/stockton-render/src/draw/camera.rs index 495e6a2..62784de 100644 --- a/stockton-render/src/draw/camera.rs +++ b/stockton-render/src/draw/camera.rs @@ -7,9 +7,9 @@ use stockton_types::{ Vector3, }; +use crate::Renderer; - - +use super::DrawPass; fn euler_to_direction(euler: &Vector3) -> Vector3 { let pitch = euler.x; @@ -25,11 +25,11 @@ fn euler_to_direction(euler: &Vector3) -> Vector3 { #[system(for_each)] #[filter(maybe_changed::<Transform>() | maybe_changed::<CameraSettings>())] -pub fn calc_vp_matrix( +pub fn calc_vp_matrix<DP: DrawPass + 'static>( transform: &Transform, settings: &CameraSettings, matrix: &mut CameraVPMatrix, - #[state] ratio: &mut f32, + #[resource] renderer: &Renderer<DP>, ) { // Get look direction from euler angles let direction = euler_to_direction(&transform.rotation); @@ -43,7 +43,12 @@ pub fn calc_vp_matrix( // Converts camera space to screen space let projection_matrix = { - let mut temp = perspective_lh_zo(*ratio, settings.fov, settings.near, settings.far); + let mut temp = perspective_lh_zo( + renderer.get_aspect_ratio(), + settings.fov, + settings.near, + settings.far, + ); // Vulkan's co-ord system is different from OpenGLs temp[(1, 1)] *= -1.0; |