diff options
| author | LLLL Colonq <llll@colonq> | 2024-04-02 12:54:43 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2024-04-02 12:54:43 -0400 |
| commit | 17eb85df48b64dd9d391cad28f58355e05ed2855 (patch) | |
| tree | 3d997324d3efc1cefc82861e058ca8badbe4dc16 /src | |
| parent | dd7f375f67251467e9799961428f87258df7282f (diff) | |
Update
Diffstat (limited to 'src')
| -rw-r--r-- | src/shader.rs | 9 | ||||
| -rw-r--r-- | src/state.rs | 2 | ||||
| -rw-r--r-- | src/texture.rs | 8 |
3 files changed, 18 insertions, 1 deletions
diff --git a/src/shader.rs b/src/shader.rs index 6bcae3c..64ece63 100644 --- a/src/shader.rs +++ b/src/shader.rs @@ -163,6 +163,15 @@ impl Shader { ); } + 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; + self.set_vec3( + ctx, "texture_offset", + &glam::Vec3::new((x % inc) as f32 * ratio, (y % inc) as f32 * ratio, count) + ); + } + pub fn bind(&self, ctx: &context::Context) { unsafe { ctx.gl.use_program(Some(self.program)); diff --git a/src/state.rs b/src/state.rs index 90ad25c..d2b9bad 100644 --- a/src/state.rs +++ b/src/state.rs @@ -143,7 +143,7 @@ impl State { pub fn bind_3d(&mut self, ctx: &context::Context, shader: &shader::Shader) { shader.bind(ctx); - shader.set_mat4(&ctx, "projection", &self.projection); + shader.set_mat4(ctx, "projection", &self.projection); shader.set_mat4(ctx, "view", &self.view()); shader.set_vec3( ctx, "light_ambient_color", diff --git a/src/texture.rs b/src/texture.rs index a7c9893..2da2247 100644 --- a/src/texture.rs +++ b/src/texture.rs @@ -42,6 +42,14 @@ impl Texture { } } + pub fn set_linear_filtering(&self, ctx: &context::Context) { + unsafe { + ctx.gl.bind_texture(glow::TEXTURE_2D, Some(self.tex)); + ctx.gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MIN_FILTER, glow::NEAREST_MIPMAP_NEAREST as i32); + ctx.gl.tex_parameter_i32(glow::TEXTURE_2D, glow::TEXTURE_MAG_FILTER, glow::NEAREST_MIPMAP_NEAREST as i32); + } + } + pub fn bind(&self, ctx: &context::Context) { unsafe { ctx.gl.active_texture(glow::TEXTURE0); |
