[−][src]Enum nannou::app::LoopMode
The mode in which the App is currently running the event loop and emitting Update
events.
Variants
Rate
Specifies that the application is continuously looping at a consistent rate.
An application running in the Rate loop mode will behave as follows:
-
Poll for and collect all pending user input.
event
is then called with all application events that have occurred. -
event
is called with anUpdate
event. -
Check the time and sleep for the remainder of the
update_interval
then go to 1.
view
is called at an arbitraty rate by the vulkan swapchain for each window. It uses
whatever the state of the user's model happens to be at that moment in time.
Fields of Rate
update_interval: Duration
The minimum interval between emitted updates.
Wait
Waits for user input events to occur before calling event
with an Update
event.
This is particularly useful for low-energy GUIs that only need to update when some sort of input has occurred. The benefit of using this mode is that you don't waste CPU cycles looping or updating when you know nothing is changing in your model or view.
Fields of Wait
RefreshSync
Synchronises Update
events with requests for a new image by the swapchain for each
window in order to achieve minimal latency between the state of the model and what is
displayed on screen. This mode should be particularly useful for interactive applications
and games where minimal latency between user input and the display image is essential.
The result of using this loop mode is similar to using vsync in traditional applications. E.g. if you have one window running on a monitor with a 60hz refresh rate, your update will get called at a fairly consistent interval that is close to 60 times per second.
It is worth noting that, in the case that you have more than one window and they are
situated on different displays with different refresh rates, update
will almost certainly
not be called at a consistent interval. Instead, it will be called as often as necessary -
if it has been longer than minimum_update_interval
or if some user input was received
since the last Update
. That said, each Update
event contains the duration since the
last Update
occurred, so as long as all time-based state (like animations or physics
simulations) are driven by this, the update
interval consistency should not cause issues.
The Swapchain
The purpose of the swapchain for each window is to synchronise the presentation of images
(calls to view
in nannou) with the refresh rate of the screen. You can learn more about
the swap chain
here.
Fields of RefreshSync
minimum_update_interval: Duration
The minimum duration that must occur between calls to update
. Under the RefreshSync
mode, the application loop will attempt to emit an Update
event once every time a new
image is acquired from a window's swapchain. Thus, this value is very useful when
working with multiple windows in order to avoid updating at an unnecessarily high rate.
We recommend using a Duration
that is roughly half the duration between refreshes of
the window on the display with the highest refresh rate. For example, if the highest
display refresh rate is 60hz (with an interval of ~16ms) a suitable
minimum_update_interval
might be 8ms. This should result in update
being called
once every 16ms regardless of the number of windows.
windows: Option<HashSet<Id>>
The windows to which Update
events should be synchronised.
If this is Some
, an Update
will only occur for those windows that are contained
within this set. This is particularly useful if you only want to synchronise your
updates with one or more "main" windows and you don't mind so much about the latency
for the rest.
If this is None
(the default case), Update
events will be synchronised with all
windows.
Methods
impl LoopMode
[src]
pub const DEFAULT_RATE_FPS: f64
[src]
pub const DEFAULT_UPDATES_FOLLOWING_EVENT: usize
[src]
pub fn rate_fps(fps: f64) -> Self
[src]
Specify the Rate mode with the given frames-per-second.
pub fn wait(updates_following_event: usize) -> Self
[src]
Specify the Wait mode with the given number of updates following each non-Update
event.
Uses the default update interval.
pub fn wait_with_max_fps(updates_following_event: usize, max_fps: f64) -> Self
[src]
Specify the Wait mode with the given number of updates following each non-Update
event.
Waits long enough to ensure loop iteration never occurs faster than the given max_fps
.
pub fn wait_with_interval(
updates_following_event: usize,
update_interval: Duration
) -> Self
[src]
updates_following_event: usize,
update_interval: Duration
) -> Self
Specify the Wait mode with the given number of updates following each non-Update
event.
Waits long enough to ensure loop iteration never occurs faster than the given max_fps
.
pub fn refresh_sync() -> Self
[src]
A simplified constructor for the default RefreshSync
loop mode.
Assumes a display refresh rate of ~60hz and in turn specifies a minimum_update_latency
of
~8.33ms. The windows
field is set to None
.
Trait Implementations
impl PartialEq<LoopMode> for LoopMode
[src]
impl Clone for LoopMode
[src]
fn clone(&self) -> LoopMode
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for LoopMode
[src]
impl Debug for LoopMode
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Style for T where
T: Any + Debug + PartialEq<T>,
[src]
T: Any + Debug + PartialEq<T>,
impl<T> Content for T
[src]
fn ref_from_ptr(ptr: *mut c_void, size: usize) -> Option<*mut T>
[src]
fn is_size_suitable(size: usize) -> bool
[src]
fn indiv_size() -> usize
[src]
impl<T> SafeBorrow<T> for T
[src]
impl<T> Erased for T
impl<S> FromSample<S> for S
[src]
fn from_sample_(s: S) -> S
[src]
impl<T, U> ToSample<U> for T where
U: FromSample<T>,
[src]
U: FromSample<T>,
fn to_sample_(self) -> U
[src]
impl<S, T> Duplex<S> for T where
T: FromSample<S> + ToSample<S>,
[src]
T: FromSample<S> + ToSample<S>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.