pub fn run_windowed<P, F>(
config: WindowConfig,
presenter: P,
app_loop: F,
) -> Result<(), EventLoopError>Expand description
Open a window and drive app_loop from the winit event loop.
On native this blocks the calling thread until the loop exits; on wasm it
returns immediately and the loop continues on requestAnimationFrame.
The closure receives &mut Terminal<WindowBackend<P>> and is called on
every frame tick. Window close pushes Event::Close into the event
queue rather than exiting: the game decides when to terminate.
§Presenting is automatic
Unlike run_blocking, this driver calls
Terminal::present for you, once, right after app_loop returns each frame: you no longer
need to (and, for a stale-content bug fixed by this behavior, should not rely on remembering
to) call it yourself inside app_loop. Calling it yourself is still supported and has no ill
effect (the driver detects it already ran and skips its own call), for example if you also want
to call Terminal::present to observe its Result directly.
§Errors
Returns [winit::error::EventLoopError] if the event loop cannot be
created or fails while running.