count_frame Subroutine

private subroutine count_frame(self, started)

Count a frame for the frame rate (render_stats): its duration, and the rate over about half a second.

Arguments

Type IntentOptional Attributes Name
type(WindowProxy), intent(inout) :: self
real(kind=wp), intent(in) :: started

the wall time frame() started (s)


Calls

proc~~count_frame~~CallsGraph proc~count_frame count_frame proc~wall_time wall_time proc~count_frame->proc~wall_time

Called by

proc~~count_frame~~CalledByGraph proc~count_frame count_frame proc~frame WindowProxy%frame proc~frame->proc~count_frame proc~resize WindowProxy%resize proc~resize->proc~frame proc~run WindowProxy%run proc~run->proc~frame

Source Code

    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