From c2c0cf75855a1310aa7a7b7a00f940c12de5fb61 Mon Sep 17 00:00:00 2001 From: Lucas Schumacher Date: Sun, 5 May 2024 21:08:50 -0400 Subject: [PATCH] Add waterfall scrolling --- src/app/waterfall.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/waterfall.rs b/src/app/waterfall.rs index db54f07..257fa99 100644 --- a/src/app/waterfall.rs +++ b/src/app/waterfall.rs @@ -79,6 +79,10 @@ impl Waterfall { ); self.offset = (self.offset + 1) % 300; + if let Some(uniform) = gl.get_uniform_location(self.program, "offset") { + gl.uniform_1_f32(Some(&uniform), self.offset as f32 / 300.0); + } + // Draw the elements gl.draw_elements(glow::TRIANGLES, 6, glow::UNSIGNED_INT, 0); @@ -219,10 +223,11 @@ impl Waterfall { // texture sampler uniform sampler2D texture1; + uniform float offset; void main() { - FragColor = texture(texture1, TexCoord); + FragColor = texture(texture1, vec2(TexCoord.x, TexCoord.y + offset)); } "#, );