From 5e9af0aca785eaaf55ecbfdea50dc8cb07d3b68c Mon Sep 17 00:00:00 2001 From: "Adrian G L (aider)" Date: Mon, 15 Sep 2025 15:45:30 +0200 Subject: [PATCH] feat: add uniform transform matrix with modifiable elements in main.rs --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index 7df1d18..3e99a2a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -236,6 +236,8 @@ fn main() { .attach_file("./shaders/simple.frag") .link() }; + // get uniform location for the matrix (named `transform` in your vertex shader) + let transform_loc = unsafe { simple_shader.get_uniform_location("transform") }; // Used to demonstrate keyboard handling for exercise 2. let mut _arbitrary_number = 0.0; // feel free to remove @@ -298,6 +300,11 @@ fn main() { // == // Issue the necessary gl:: commands to draw your scene here simple_shader.activate(); + // build and send the transform matrix (start from identity) + let mut transform = glm::identity(); + // modify element (0,0) here; change indices to test a, b, c, d, e, f, etc. + transform[(0,0)] = elapsed.sin(); + gl::UniformMatrix4fv(transform_loc, 1, gl::FALSE, transform.as_ptr()); gl::BindVertexArray(my_vao); gl::DrawElements( gl::TRIANGLES,