pub struct FixedClock { /* private fields */ }Expand description
Fixed-timestep clock. See the crate docs.
Implementations§
Source§impl FixedClock
impl FixedClock
Sourcepub const fn new(config: TickConfig, first_due: u32) -> FixedClock
pub const fn new(config: TickConfig, first_due: u32) -> FixedClock
A clock whose first tick is due at VBlank first_due.
Sourcepub fn realign(&mut self, first_due: u32)
pub fn realign(&mut self, first_due: u32)
Forget any owed time and make the next tick due at first_due.
Call after a load, a pause menu or anything else that should not be
caught up. Not counted as dropped ticks.
Sourcepub fn due(&mut self, now: u32) -> bool
pub fn due(&mut self, now: u32) -> bool
true when a tick is due at VBlank now: run one tick, then ask
again. The tick is counted as run when this returns true.
Reading now fresh each time lets a frame keep catching up while its
own ticks take time, exactly as a while vblank >= next loop does.
Sourcepub fn consume(&mut self)
pub fn consume(&mut self)
Record one tick as run: advance the deadline and the counters. The
caller has already decided it was due (see is_due).
Sourcepub fn end_frame(&mut self)
pub fn end_frame(&mut self)
Close the current frame: record how many ticks it ran and start counting the next frame’s.
Sourcepub const fn frame_ticks(&self) -> u16
pub const fn frame_ticks(&self) -> u16
Ticks run so far in the current frame.
Sourcepub fn phase_q12(&self, now: u32) -> u16
pub fn phase_q12(&self, now: u32) -> u16
How far VBlank now is from the last tick toward the next one, in
Q12 (0 = the last tick has just been reached, 4096 = the next one is
due). Renderers draw lerp(previous, latest, phase): one tick of
latency in exchange for motion that moves on every rendered frame at
any tick rate. A game ticking every VBlank can simply draw the latest
state instead.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Zero the consistency counters (for example at the start of a level).
Trait Implementations§
Source§impl Clone for FixedClock
impl Clone for FixedClock
Source§fn clone(&self) -> FixedClock
fn clone(&self) -> FixedClock
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FixedClock
impl Debug for FixedClock
Source§impl PartialEq for FixedClock
impl PartialEq for FixedClock
impl Copy for FixedClock
impl Eq for FixedClock
impl StructuralPartialEq for FixedClock
Auto Trait Implementations§
impl Freeze for FixedClock
impl RefUnwindSafe for FixedClock
impl Send for FixedClock
impl Sync for FixedClock
impl Unpin for FixedClock
impl UnsafeUnpin for FixedClock
impl UnwindSafe for FixedClock
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)