From 3efd3026d22c71e95a853985f3f50f52147d287e Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Sun, 13 Oct 2024 23:46:06 -0400 Subject: Instanced rendering, mouse move event --- src/shader.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/shader.rs') diff --git a/src/shader.rs b/src/shader.rs index ec0f24b..71f2a7c 100644 --- a/src/shader.rs +++ b/src/shader.rs @@ -188,14 +188,14 @@ impl Shader { self.set_mat4(&ctx, "normal_matrix", &position.inverse().transpose()); } - pub fn set_position_2d(&self, ctx: &context::Context, pos: &glam::Vec2, dims: &glam::Vec2) { + pub fn set_position_2d_helper(&self, ctx: &context::Context, pos: &glam::Vec2, dims: &glam::Vec2, rot: &glam::Quat) { let halfwidth = dims.x / 2.0; let halfheight = dims.y / 2.0; self.set_mat4( &ctx, "position", &glam::Mat4::from_scale_rotation_translation( glam::Vec3::new(halfwidth, halfheight, 1.0), - glam::Quat::IDENTITY, + rot.clone(), glam::Vec3::new( -context::RENDER_WIDTH / 2.0 + pos.x + halfwidth, context::RENDER_HEIGHT / 2.0 - pos.y - halfheight, @@ -205,6 +205,10 @@ impl Shader { ); } + pub fn set_position_2d(&self, ctx: &context::Context, pos: &glam::Vec2, dims: &glam::Vec2) { + self.set_position_2d_helper(ctx, pos, dims, &glam::Quat::IDENTITY) + } + pub fn set_texture_offset(&self, ctx: &context::Context, inc: i32, x: i32, y: i32) { let count = inc as f32; let ratio = 1.0 / count; -- cgit v1.2.3