gled_ui/render_state.rs
1//! The GPU egui draws with, which also renders the effect thumbnails and the
2//! LED preview. Set once when the app starts, on the desktop and in the
3//! browser alike.
4
5use std::sync::OnceLock;
6
7use eframe::egui_wgpu::RenderState;
8
9static RENDER_STATE: OnceLock<RenderState> = OnceLock::new();
10
11/// Keeps the app's render state. Returns `false` if one was set before.
12pub fn set(render_state: RenderState) -> bool {
13 RENDER_STATE.set(render_state).is_ok()
14}
15
16/// The app's render state, once the app started.
17pub(crate) fn get() -> Option<RenderState> {
18 RENDER_STATE.get().cloned()
19}