Skip to main content
← PSoXide SDK guides and examples · SDK f2fec1c301f1 · All Cargo features enabled; check feature gates before use.

FixedClock

Struct FixedClock 

Source
pub struct FixedClock { /* private fields */ }
Expand description

Fixed-timestep clock. See the crate docs.

Implementations§

Source§

impl FixedClock

Source

pub const fn new(config: TickConfig, first_due: u32) -> FixedClock

A clock whose first tick is due at VBlank first_due.

Source

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.

Source

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.

Source

pub fn is_due(&self, now: u32) -> bool

true when a tick is due at VBlank now, without running it and ignoring the catch-up policy. For schedulers that decide first and commit later with consume; game loops use due.

Source

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).

Source

pub fn end_frame(&mut self)

Close the current frame: record how many ticks it ran and start counting the next frame’s.

Source

pub const fn tick(&self) -> u32

Ticks run since construction.

Source

pub const fn frame_ticks(&self) -> u16

Ticks run so far in the current frame.

Source

pub const fn rate(&self) -> TickRate

Tick length in VBlanks.

Source

pub const fn next_due(&self) -> u32

VBlank at which the next tick is due.

Source

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.

Source

pub const fn stats(&self) -> TickStats

Consistency counters.

Source

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

Source§

fn clone(&self) -> FixedClock

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FixedClock

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for FixedClock

Source§

fn eq(&self, other: &FixedClock) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for FixedClock

Source§

impl Eq for FixedClock

Source§

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where 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>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where 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>

Performs the conversion.