Browse Source

Review GetFPS()

pull/1842/head
Ray 3 years ago
parent
commit
115cc7dede
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      src/core.c

+ 7
- 1
src/core.c View File

@ -2635,6 +2635,9 @@ void SetTargetFPS(int fps)
// NOTE: We calculate an average framerate
int GetFPS(void)
{
int fps = 0;
#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL)
#define FPS_CAPTURE_FRAMES_COUNT 30 // 30 captures
#define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 millisecondes
#define FPS_STEP (FPS_AVERAGE_TIME_SECONDS/FPS_CAPTURE_FRAMES_COUNT)
@ -2654,8 +2657,11 @@ int GetFPS(void)
history[index] = fpsFrame/FPS_CAPTURE_FRAMES_COUNT;
average += history[index];
}
fps = (int)roundf(1.0f/average);
#endif
return (int)roundf(1.0f/average);
return fps;
}
// Get time in seconds for last frame drawn (delta time)

Loading…
Cancel
Save