pub fn update(&mut self, ts: u32) {
        let timer = &mut self.timer;
        let print_buf = &mut self.print_buf;
        let last_frame_ts = self.last_frame_ts;

        // Check if we need to redraw. This ignores the time deviation.
        // When yes, clear the print buffer, and write new text to it with the current FPS.
        // --------------------------------------------------------------------------------
        timer.check(ts, |_off| {
            print_buf.clear();
            write!(
                print_buf,
                "FPS: {:.2}",
                1000.0 / (ts - last_frame_ts) as f64
            )
            .unwrap();
        });

        self.last_frame_ts = ts;
    }
/// Update function for the FPS counter. It needs per game loop update to measure FPS,
/// and to check its redraw timer.
Update function for the FPS counter. It needs per game loop update to measure FPS,
and to check its redraw timer.
Update function for the FPS counter . It needs per game loop update to measure FPS and to check its redraw timer .
pub fn update(&mut self, ts: u32) {
        let timer = &mut self.timer;
        let print_buf = &mut self.print_buf;
        let last_frame_ts = self.last_frame_ts;
        // Check if we need to redraw. This ignores the time deviation.
        // When yes, clear the print buffer, and write new text to it with the current FPS.
        // --------------------------------------------------------------------------------
        timer.check(ts, |_off| {
            print_buf.clear();
            write!(
                print_buf,
                "FPS: {:.2}",
                1000.0 / (ts - last_frame_ts) as f64
            )
            .unwrap();
        });
        self.last_frame_ts = ts;
    }
pub fn update ( & mut self , ts : u32 ) { let timer = & mut self . timer ; let print_buf = & mut self . print_buf ; let last_frame_ts = self . last_frame_ts ; // Check if we need to redraw. This ignores the time deviation. // When yes, clear the print buffer, and write new text to it with the current FPS. // -------------------------------------------------------------------------------- timer . check ( ts , | _off | { print_buf . clear ( ) ; write ! ( print_buf " " 1000.0 ( ts last_frame_ts ) as f64 ) . unwrap ( ) ; } ) ; self . last_frame_ts = ts ; }
Update function for the FPS counter.
Update function for the FPS counter .
&mut self
ts
u32
&mut self
ts
u32