Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GetFPS so it doesn't hold on last time from previous window #3410

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/rcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,14 +1230,16 @@ int GetFPS(void)

static int index = 0;
static float history[FPS_CAPTURE_FRAMES_COUNT] = { 0 };
static float average = 0, last = 0;
static float average = 0, wait = FPS_STEP;
float fpsFrame = GetFrameTime();

if (fpsFrame == 0) return 0;

if ((GetTime() - last) > FPS_STEP)
wait += fpsFrame;

if (wait > FPS_STEP)
{
last = (float)GetTime();
wait = 0;
index = (index + 1)%FPS_CAPTURE_FRAMES_COUNT;
average -= history[index];
history[index] = fpsFrame/FPS_CAPTURE_FRAMES_COUNT;
Expand Down