summaryrefslogtreecommitdiff
path: root/src/state.rs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2024-04-26 14:26:22 -0400
committerLLLL Colonq <llll@colonq>2024-04-26 14:26:22 -0400
commitef27fca1e1041f8eb298d0dab6eed876786b2026 (patch)
treee52cc1552cfe982a881505f08fc74f8d0cab40cf /src/state.rs
parentd2f9bfeba00018a1109949eed5a2434a040881fe (diff)
Fix lighting, various toggles
Diffstat (limited to 'src/state.rs')
-rw-r--r--src/state.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/state.rs b/src/state.rs
index 7170a84..86b60bf 100644
--- a/src/state.rs
+++ b/src/state.rs
@@ -172,7 +172,7 @@ impl State {
)
}
- pub fn bind_3d(&mut self, ctx: &context::Context, shader: &shader::Shader) {
+ pub fn bind_3d_helper(&mut self, ctx: &context::Context, shader: &shader::Shader, plc: usize) {
shader.bind(ctx);
shader.set_mat4(ctx, "projection", &self.projection);
shader.set_mat4(ctx, "view", &self.view());
@@ -188,11 +188,19 @@ impl State {
ctx, "light_dir",
&self.lighting.2.normalize(),
);
- let plc = self.point_lights.len().min(5);
shader.set_i32(
ctx, &format!("light_count"),
plc as _,
);
+ }
+
+ pub fn bind_3d_no_point_lights(&mut self, ctx: &context::Context, shader: &shader::Shader) {
+ self.bind_3d_helper(ctx, shader, 0);
+ }
+
+ pub fn bind_3d(&mut self, ctx: &context::Context, shader: &shader::Shader) {
+ let plc = self.point_lights.len().min(5);
+ self.bind_3d_helper(ctx, shader, plc);
if plc > 0 {
let lpos: Vec<_> = self.point_lights.iter().take(plc).map(|l| l.pos).collect();
shader.set_vec3_array(