mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-12 05:31:31 +11:00
Clarify when RedrawRequested is useful (#1529)
Co-Authored-By: Osspial <osspial@gmail.com>
This commit is contained in:
parent
aabe42d252
commit
849b8f5dce
10
src/event.rs
10
src/event.rs
|
@ -81,10 +81,11 @@ pub enum Event<'a, T: 'static> {
|
||||||
///
|
///
|
||||||
/// This event is useful as a place to put your code that should be run after all
|
/// This event is useful as a place to put your code that should be run after all
|
||||||
/// state-changing events have been handled and you want to do stuff (updating state, performing
|
/// state-changing events have been handled and you want to do stuff (updating state, performing
|
||||||
/// calculations, etc) that happens as the "main body" of your event loop. If your program draws
|
/// calculations, etc) that happens as the "main body" of your event loop. If your program only draws
|
||||||
/// graphics, it's usually better to do it in response to
|
/// graphics when something changes, it's usually better to do it in response to
|
||||||
/// [`Event::RedrawRequested`](crate::event::Event::RedrawRequested), which gets emitted
|
/// [`Event::RedrawRequested`](crate::event::Event::RedrawRequested), which gets emitted
|
||||||
/// immediately after this event.
|
/// immediately after this event. Programs that draw graphics continuously, like most games,
|
||||||
|
/// can render here unconditionally for simplicity.
|
||||||
MainEventsCleared,
|
MainEventsCleared,
|
||||||
|
|
||||||
/// Emitted after `MainEventsCleared` when a window should be redrawn.
|
/// Emitted after `MainEventsCleared` when a window should be redrawn.
|
||||||
|
@ -97,6 +98,9 @@ pub enum Event<'a, T: 'static> {
|
||||||
///
|
///
|
||||||
/// During each iteration of the event loop, Winit will aggregate duplicate redraw requests
|
/// During each iteration of the event loop, Winit will aggregate duplicate redraw requests
|
||||||
/// into a single event, to help avoid duplicating rendering work.
|
/// into a single event, to help avoid duplicating rendering work.
|
||||||
|
///
|
||||||
|
/// Mainly of interest to applications with mostly-static graphics that avoid redrawing unless
|
||||||
|
/// something changes, like most non-game GUIs.
|
||||||
RedrawRequested(WindowId),
|
RedrawRequested(WindowId),
|
||||||
|
|
||||||
/// Emitted after all `RedrawRequested` events have been processed and control flow is about to
|
/// Emitted after all `RedrawRequested` events have been processed and control flow is about to
|
||||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -73,14 +73,18 @@
|
||||||
//! // Application update code.
|
//! // Application update code.
|
||||||
//!
|
//!
|
||||||
//! // Queue a RedrawRequested event.
|
//! // Queue a RedrawRequested event.
|
||||||
|
//! //
|
||||||
|
//! // You only need to call this if you've determined that you need to redraw, in
|
||||||
|
//! // applications which do not always need to. Applications that redraw continuously
|
||||||
|
//! // can just render here instead.
|
||||||
//! window.request_redraw();
|
//! window.request_redraw();
|
||||||
//! },
|
//! },
|
||||||
//! Event::RedrawRequested(_) => {
|
//! Event::RedrawRequested(_) => {
|
||||||
//! // Redraw the application.
|
//! // Redraw the application.
|
||||||
//! //
|
//! //
|
||||||
//! // It's preferrable to render in this event rather than in MainEventsCleared, since
|
//! // It's preferable for applications that do not render continuously to render in
|
||||||
//! // rendering in here allows the program to gracefully handle redraws requested
|
//! // this event rather than in MainEventsCleared, since rendering in here allows
|
||||||
//! // by the OS.
|
//! // the program to gracefully handle redraws requested by the OS.
|
||||||
//! },
|
//! },
|
||||||
//! _ => ()
|
//! _ => ()
|
||||||
//! }
|
//! }
|
||||||
|
|
Loading…
Reference in a new issue