Count a frame for the frame rate (render_stats): its duration, and the rate over about half a second.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(WindowProxy), | intent(inout) | :: | self | |||
| real(kind=wp), | intent(in) | :: | started |
the wall time frame() started (s) |
subroutine count_frame(self, started) type(WindowProxy), intent(inout) :: self real(wp), intent(in) :: started !! the wall time frame() started (s) real(wp), parameter :: span = 0.5_wp !! s: the rate's averaging time real(wp) :: now, elapsed now = wall_time() self%last_frame_ms = 1000.0_wp * (now - started) if (self%rate_start < 0.0_wp) then self%rate_start = now self%rate_frames = 0 return end if self%rate_frames = self%rate_frames + 1 elapsed = now - self%rate_start if (elapsed >= span) then self%fps_ = self%rate_frames / elapsed self%frame_ms_ = 1000.0_wp * elapsed / self%rate_frames self%rate_start = now self%rate_frames = 0 end if end subroutine count_frame