summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helpers.js2
-rw-r--r--src/shader.rs9
-rw-r--r--src/state.rs2
-rw-r--r--src/texture.rs8
4 files changed, 19 insertions, 2 deletions
diff --git a/helpers.js b/helpers.js
index 20b86f4..aaaafa1 100644
--- a/helpers.js
+++ b/helpers.js
@@ -4,7 +4,7 @@ export async function js_track_resized_setup() {
window.addEventListener("resize", () => {
resized = true;
});
-};
+}
export function js_poll_resized() {
let ret = resized;
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);