summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2025-11-04 21:31:49 -0500
committerLLLL Colonq <llll@colonq>2025-11-04 21:31:49 -0500
commit68d8783f858a771c64b4e151a0e92ed40ca18a99 (patch)
tree26362b485d00a60dc183ece2cad4e3e3682c40cb
parentaa6cefb286f56773cf1840eb82e5e0f19370de0b (diff)
Update set_position_2d and set_position_3d
-rw-r--r--Cargo.lock19
-rw-r--r--crates/teleia/src/shader.rs14
2 files changed, 26 insertions, 7 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d772325..eacf1a9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -718,6 +718,15 @@ dependencies = [
]
[[package]]
+name = "env"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bc95de49ad098572c02d3fbf368c9a020bfff5ae78483685b77f51d8a7e9486d"
+dependencies = [
+ "num_threads",
+]
+
+[[package]]
name = "env_filter"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1671,6 +1680,15 @@ dependencies = [
]
[[package]]
+name = "num_threads"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5c7398b9c8b70908f6371f47ed36737907c87c52af34c268fed0bf0ceb92ead9"
+dependencies = [
+ "libc",
+]
+
+[[package]]
name = "objc-sys"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2724,6 +2742,7 @@ dependencies = [
name = "teleia_macros"
version = "0.1.0"
dependencies = [
+ "env",
"heck",
"litrs",
"walkdir",
diff --git a/crates/teleia/src/shader.rs b/crates/teleia/src/shader.rs
index 178833a..5a343ef 100644
--- a/crates/teleia/src/shader.rs
+++ b/crates/teleia/src/shader.rs
@@ -2,7 +2,7 @@ use std::collections::HashMap;
use glow::HasContext;
-use crate::{context, mesh};
+use crate::{context, state, mesh};
const COMMON_VERT: &'static str = include_str!("assets/shaders/common/vert.glsl");
const COMMON_FRAG: &'static str = include_str!("assets/shaders/common/frag.glsl");
@@ -210,12 +210,12 @@ impl Shader {
}
}
- pub fn set_position_3d(&self, ctx: &context::Context, position: &glam::Mat4) {
+ pub fn set_position_3d(&self, ctx: &context::Context, _st: &state::State, position: &glam::Mat4) {
self.set_mat4(&ctx, "position", &position);
self.set_mat4(&ctx, "normal_matrix", &position.inverse().transpose());
}
- pub fn set_position_2d_helper(&self, ctx: &context::Context, pos: &glam::Vec2, dims: &glam::Vec2, rot: &glam::Quat) {
+ pub fn set_position_2d_helper(&self, ctx: &context::Context, st: &state::State, pos: &glam::Vec2, dims: &glam::Vec2, rot: &glam::Quat) {
let halfwidth = dims.x / 2.0;
let halfheight = dims.y / 2.0;
self.set_mat4(
@@ -224,16 +224,16 @@ impl Shader {
glam::Vec3::new(halfwidth, halfheight, 1.0),
rot.clone(),
glam::Vec3::new(
- -ctx.render_width / 2.0 + pos.x + halfwidth,
- ctx.render_height / 2.0 - pos.y - halfheight,
+ -st.render_dims.x / 2.0 + pos.x + halfwidth,
+ st.render_dims.y / 2.0 - pos.y - halfheight,
0.0,
),
)
);
}
- 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_position_2d(&self, ctx: &context::Context, st: &state::State, pos: &glam::Vec2, dims: &glam::Vec2) {
+ self.set_position_2d_helper(ctx, st, pos, dims, &glam::Quat::IDENTITY)
}
pub fn set_texture_offset(&self, ctx: &context::Context, inc: i32, x: i32, y: i32) {