render: add a frame parameter to all shaders

This commit is contained in:
2024-11-23 14:50:28 +01:00
parent 73c3ced3d7
commit 9dff0119a4
3 changed files with 10 additions and 7 deletions

View File

@ -40,7 +40,8 @@ T::Color: HardwarePixel,
pixmap: StrideMapping,
target: T,
pixbuf: [T::Color; PIXEL_NUM],
max_mw: u32
max_mw: u32,
frame: usize
}
impl<T: SmartLedsWrite, S: Surface, const PIXEL_NUM: usize> Debug for SmartLedDisplay<T, S, PIXEL_NUM> where
@ -63,7 +64,8 @@ T::Color: HardwarePixel,
surfaces: Some(SurfacePool::new()),
target,
max_mw,
pixmap: StrideMapping::new()
pixmap: StrideMapping::new(),
frame: 0
}
}
}
@ -110,7 +112,7 @@ Rgb<u8>: From<T::Color>
if idx >= PIXEL_NUM {
continue;
}
self.pixbuf[idx] = self.pixbuf[idx].saturating_add(shader.draw(&virt_coords));
self.pixbuf[idx] = self.pixbuf[idx].saturating_add(shader.draw(&virt_coords, self.frame));
}
})
}
@ -134,6 +136,7 @@ Rgb<u8>: From<T::Color> {
if let Err(_) = self.target.write(brightness(self.pixbuf.iter().cloned().map(|x| { x.into() }), b)) {
panic!("Could not write frame");
}
self.frame += 1;
}
}