feat: apply translation and perspective projection to transform matrix before shader upload
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user