mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-08 02:46:28 +00:00
Review GetFPS()
This commit is contained in:
@@ -2635,6 +2635,9 @@ void SetTargetFPS(int fps)
|
|||||||
// NOTE: We calculate an average framerate
|
// NOTE: We calculate an average framerate
|
||||||
int GetFPS(void)
|
int GetFPS(void)
|
||||||
{
|
{
|
||||||
|
int fps = 0;
|
||||||
|
|
||||||
|
#if !defined(SUPPORT_CUSTOM_FRAME_CONTROL)
|
||||||
#define FPS_CAPTURE_FRAMES_COUNT 30 // 30 captures
|
#define FPS_CAPTURE_FRAMES_COUNT 30 // 30 captures
|
||||||
#define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 millisecondes
|
#define FPS_AVERAGE_TIME_SECONDS 0.5f // 500 millisecondes
|
||||||
#define FPS_STEP (FPS_AVERAGE_TIME_SECONDS/FPS_CAPTURE_FRAMES_COUNT)
|
#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;
|
history[index] = fpsFrame/FPS_CAPTURE_FRAMES_COUNT;
|
||||||
average += history[index];
|
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)
|
// Get time in seconds for last frame drawn (delta time)
|
||||||
|
Reference in New Issue
Block a user