From b08a38ce74c1cd26f06a4c5076b092e2e3e815b9 Mon Sep 17 00:00:00 2001 From: Adrian G L Date: Wed, 17 Sep 2025 22:10:42 +0200 Subject: [PATCH] feat: apply translation and perspective projection to transform matrix before shader upload --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index c592a97..9b2b942 100644 --- a/src/main.rs +++ b/src/main.rs @@ -315,6 +315,13 @@ fn main() { 5 => transform[(1,3)] = v, // f _ => {} } + // move scene into viewable negative z range + let translation: glm::Mat4 = glm::translation(&glm::vec3(0.0, 0.0, -5.0)); + transform = translation * transform; + // apply perspective projection: (aspect, fovy radians, near, far) + let projection: glm::Mat4 = + glm::perspective(window_aspect_ratio, std::f32::consts::PI / 4.0, 1.0, 100.0); + transform = projection * transform; gl::UniformMatrix4fv(transform_loc, 1, gl::FALSE, transform.as_ptr()); gl::BindVertexArray(my_vao); gl::DrawElements(