Can now apply a shader using the animation's timer but not sure if there should be shaders on animations or outside or both.

This commit is contained in:
Zed A. Shaw 2026-02-09 13:58:28 -05:00
parent 0d481a5ab7
commit 80f100f223
5 changed files with 29 additions and 10 deletions

View file

@ -50,10 +50,16 @@ namespace animate2 {
sprite.setTextureRect(rect);
}
void Animate2::apply_effect(std::shared_ptr<sf::Shader> effect) {
dbc::check(effect != nullptr, "can't apply null effect");
effect->setUniform("u_time", sequence.timer.getElapsedTime().asSeconds());
sf::Vector2f u_resolution{float(sheet.frame_width), float(sheet.frame_height)};
effect->setUniform("u_resolution", u_resolution);
}
void Animate2::play_sound() {
// BUG: this can be optimized way better
if(sounds.contains(form_name)) {
fmt::println("Playing sound for {}", form_name);
for(auto& [at_frame, sound_name] : sounds.at(form_name)) {
if(sequence.current == at_frame) {
sound::play(sound_name);