Skip to main content

run_windowed

Function run_windowed 

Source
pub fn run_windowed<P, F>(
    config: WindowConfig,
    presenter: P,
    app_loop: F,
) -> Result<(), EventLoopError>
where P: Presenter + 'static, F: FnMut(&mut Terminal<WindowBackend<P>>) + 'static,
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.

Unlike run_on, this driver presents automatically: see https://main.retroglyph.dev/book/explanation/architecture.html#presenting-is-automatic.

ยงErrors

Returns EventLoopError if the event loop cannot be created or fails while running.