From 72c0cbcb38732b698d33d52459fed67af56ee2ec Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 31 Jan 2026 15:36:45 +0100 Subject: feat: Implement Sequence and Effect system for demo choreography Refactors the rendering pipeline into a modular Sequence/Effect system. 'MainSequence' manages the final frame rendering and a list of 'Sequence' layers. 'Sequence' manages a timeline of 'Effect' objects (start/end/priority). Concrete effects (Heptagon, Particles) are moved to 'demo_effects.cc'. Updates main loop to pass beat and aspect ratio. --- src/gpu/demo_effects.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/gpu/demo_effects.h (limited to 'src/gpu/demo_effects.h') diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h new file mode 100644 index 0000000..81321d9 --- /dev/null +++ b/src/gpu/demo_effects.h @@ -0,0 +1,40 @@ +// This file is part of the 64k demo project. +// It declares the concrete effects used in the demo. + +#pragma once +#include "effect.h" +#include "gpu.h" +#include + +class HeptagonEffect : public Effect { +public: + HeptagonEffect(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); + void render(WGPURenderPassEncoder pass, float time, float beat, + float intensity, float aspect_ratio) override; + +private: + WGPUQueue queue_; + RenderPass pass_; + GpuBuffer uniforms_; +}; + +class ParticlesEffect : public Effect { +public: + ParticlesEffect(WGPUDevice device, WGPUQueue queue, WGPUTextureFormat format); + void compute(WGPUCommandEncoder encoder, float time, float beat, + float intensity, float aspect_ratio) override; + void render(WGPURenderPassEncoder pass, float time, float beat, + float intensity, float aspect_ratio) override; + +private: + WGPUQueue queue_; + ComputePass compute_pass_; + RenderPass render_pass_; + GpuBuffer particles_buffer_; + GpuBuffer uniforms_; +}; + +// Factory +std::shared_ptr create_demo_sequence(WGPUDevice device, + WGPUQueue queue, + WGPUTextureFormat format); -- cgit v1.2.3