Expand description
Flame screensaver for egui.
A windswept fire rendered from a fractal-noise fragment shader, ported from Blake Bowen’s “Flame in the wind” CodePen, itself adapting a shader by Shadertoy user @kuvkar.
Like the original, this runs the shader on the GPU: a fullscreen triangle
is drawn through an egui::PaintCallback using egui_glow, so the
per-pixel math runs in parallel across the GPU’s shader cores instead of
serially on the CPU. This requires the host eframe::App to use the
glow rendering backend (not wgpu) — FlameBackground::paint
simply skips drawing if no glow::Context is available.
Rendering is capped at 30 FPS. If the hardware cannot sustain that rate, frames are painted as fast as possible without any artificial delay.
§Usage
use egui_screensaver_flame::FlameBackground;
struct MyApp {
flame: FlameBackground,
}
impl eframe::App for MyApp {
fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) {
let ctx = ui.ctx().clone();
// Call paint once per frame before drawing any UI windows so the
// screensaver sits on the background layer behind everything else.
self.flame.paint(&ctx, frame.gl());
}
}Structs§
- Flame
Background - Flame screensaver state.