diff options
| author | LLLL Colonq <llll@colonq> | 2025-02-16 01:53:39 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-02-16 01:53:39 -0500 |
| commit | f2d6e8ac38e8ade9bebc355f4c0e97760f6f1649 (patch) | |
| tree | 46906fcccecb63cd36ebc9023135751c55279014 /src/common/overlay/throwshade.rs | |
| parent | 472eadbc178ed70a4acc9339d34f0bb2fa04b0a1 (diff) | |
Throwing shade
Diffstat (limited to 'src/common/overlay/throwshade.rs')
| -rw-r--r-- | src/common/overlay/throwshade.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/common/overlay/throwshade.rs b/src/common/overlay/throwshade.rs index d7ac430..c6b8f2e 100644 --- a/src/common/overlay/throwshade.rs +++ b/src/common/overlay/throwshade.rs @@ -4,20 +4,30 @@ const VERT: &'static str = include_str!("assets/shaders/throwshade/vert.glsl"); const FRAG: &'static str = include_str!("assets/shaders/throwshade/frag.glsl"); pub struct ThrowShade { + pub tickset: u64, + pub timeset: f64, pub shader: Option<shader::Shader>, } impl ThrowShade { pub fn new() -> Self { Self { + tickset: 0, + timeset: 0.0, shader: None, } } - pub fn set(&mut self, ctx: &context::Context, src: &str) { + pub fn set(&mut self, ctx: &context::Context, st: &state::State, src: &str) -> Result<(), String> { let fsrc = format!("{}\n{}\n", FRAG, src); + self.tickset = st.tick; + if let Ok(dur) = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH) { + self.timeset = dur.as_secs_f64(); + log::info!("the time: {}", self.timeset); + } if let Some(s) = &mut self.shader { - s.replace(ctx, VERT, &fsrc); + s.replace(ctx, VERT, &fsrc)?; } else { - self.shader = Some(shader::Shader::new_nolib(ctx, VERT, &fsrc)); + self.shader = Some(shader::Shader::new_helper(ctx, VERT, &fsrc)?); } + Ok(()) } } |
