summaryrefslogtreecommitdiff
path: root/opengl-bindings/src/shader.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-03-20 14:05:50 +0100
committerHampusM <hampus@hampusmat.com>2026-03-20 14:05:50 +0100
commit3f77642c378008bca3fc8eb8d692365ec371fa34 (patch)
treed23539d74b6f111b9fbd50ff4d811ef48e688b17 /opengl-bindings/src/shader.rs
parent9a442786c45ce05b4dc42cb07b654eac7671b35d (diff)
feat(opengl-bindings): add shader::Program set_uniform_at_location fn
Diffstat (limited to 'opengl-bindings/src/shader.rs')
-rw-r--r--opengl-bindings/src/shader.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/opengl-bindings/src/shader.rs b/opengl-bindings/src/shader.rs
index 5ed66a2..d3ce530 100644
--- a/opengl-bindings/src/shader.rs
+++ b/opengl-bindings/src/shader.rs
@@ -3,8 +3,8 @@ use std::ptr::null_mut;
use safer_ffi::layout::ReprC;
-use crate::data_types::{Matrix, Vec3};
use crate::CurrentContextWithFns;
+use crate::data_types::{Matrix, Vec3};
#[derive(Debug)]
pub struct Shader
@@ -189,6 +189,16 @@ impl Program
}
}
+ pub fn set_uniform_at_location(
+ &self,
+ current_context: &CurrentContextWithFns<'_>,
+ location: UniformLocation,
+ var: &impl UniformVariable,
+ )
+ {
+ var.set(current_context, self, location);
+ }
+
pub fn set_uniform(
&self,
current_context: &CurrentContextWithFns<'_>,
@@ -334,6 +344,14 @@ impl sealed::Sealed for Matrix<f32, 4, 4> {}
#[derive(Debug)]
pub struct UniformLocation(crate::sys::types::GLint);
+impl UniformLocation
+{
+ pub fn from_number(number: i32) -> Self
+ {
+ Self(number)
+ }
+}
+
/// Shader error.
#[derive(Debug, thiserror::Error)]
pub enum Error