Expand description
Optional desktop host for running Apps against a real wgpu
surface in a winit window.
Most native apps should use this crate instead of calling
damascene-wgpu directly:
use damascene_core::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let viewport = Rect::new(0.0, 0.0, 720.0, 480.0);
damascene_winit_wgpu::run("My Damascene App", viewport, MyApp::default())
}The host owns the event loop, window, device/queue, surface
configuration, render pass boundaries, input mapping, IME forwarding,
and animation redraw cadence. Your code owns the App: application
state, App::build, App::on_event, optional hotkeys, custom
shaders, and theme.
run takes an App and runs an event loop that:
- Calls
App::buildon every redraw, applying current hover/press visuals automatically before paint. - Routes
winitpointer events through the renderer’s hit-tester and dispatches events back viaApp::on_event. - Routes Tab/Shift-Tab through focus traversal and Enter/Space/Escape through keyboard events.
- Copies the current Damascene text selection to the native clipboard on Ctrl/Cmd+C.
- Requests a redraw whenever interaction state changes (mouse move, button down/up) so hover/press visuals are immediate.
Use run_with_config when an app has external live state. Put
per-frame state refresh in App::before_build, then pick the
redraw driver that matches the data (see the README’s meter-class
vs event-class discussion): a fixed cadence via
HostConfig::with_redraw_interval for continuously-changing
meters, or push-driven wakes via
HostConfig::with_external_wakeup for sparse events, so the
idle app renders at 0 fps. For fully custom render-loop
integration, bypass this crate and call damascene_wgpu::Runner
directly.
§Environment variables
DAMASCENE_COLOR_DEBUG=1— dump the color negotiation to stderr: the surface formats the WSI advertises, the compositor’s capabilities, the preferred-description targets (reference white, display peak,indicates_hdr), and the swapchain format the ladder settled on; re-dumped on everypreferred_changed2re-negotiation. The first stop for “why didn’t I get HDR?” — seedocs/COLOR_MANAGEMENT.md. Apps query the same state at runtime viaHostDiagnostics::hdr_active().
Modules§
- host
- Building blocks for writing a custom winit host.
Structs§
- Host
Config - Configuration for the optional native winit + wgpu host.
- Wakeup
Send + Clonehandle that wakes the running host loop from any thread and schedules one redraw.- Wakeup
Hook - External-wakeup hook stored in
HostConfig. Wraps the closure soHostConfigcan keep derivingCloneandDebug.
Traits§
- Winit
Wgpu App - Compatibility extension point for apps that use this host crate.
Functions§
- run
- Run a windowed app. Blocks until the user closes the window.
- run_
host_ app - Run a windowed app with default host configuration.
- run_
host_ app_ on_ event_ loop - Run a host-specific
WinitWgpuAppusing a caller-created winit event loop. - run_
host_ app_ with_ config - Run a windowed app with host-specific configuration.
- run_
on_ event_ loop - Run a plain
Appusing a caller-created winit event loop. - run_
with_ config - Run a windowed app with host-specific configuration.