mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-01 11:49:17 -05:00
When the frame counter gets to 0, reset the FPS average counter. This allows the window to be closed and reopened with clean FPS stats. (#3445)
This commit is contained in:
12
src/rcore.c
12
src/rcore.c
@ -484,9 +484,9 @@ void InitWindow(int width, int height, const char *title)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CORE.Time.frameCounter = 0;
|
||||||
#if defined(SUPPORT_EVENTS_AUTOMATION)
|
#if defined(SUPPORT_EVENTS_AUTOMATION)
|
||||||
events = (AutomationEvent *)RL_CALLOC(MAX_CODE_AUTOMATION_EVENTS, sizeof(AutomationEvent));
|
events = (AutomationEvent *)RL_CALLOC(MAX_CODE_AUTOMATION_EVENTS, sizeof(AutomationEvent));
|
||||||
CORE.Time.frameCounter = 0;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialize random seed
|
// Initialize random seed
|
||||||
@ -1396,6 +1396,16 @@ int GetFPS(void)
|
|||||||
static float average = 0, last = 0;
|
static float average = 0, last = 0;
|
||||||
float fpsFrame = GetFrameTime();
|
float fpsFrame = GetFrameTime();
|
||||||
|
|
||||||
|
// if we reset the window, reset the FPS info
|
||||||
|
if (CORE.Time.frameCounter == 0)
|
||||||
|
{
|
||||||
|
average = 0;
|
||||||
|
last = 0;
|
||||||
|
index = 0;
|
||||||
|
for (int i = 0; i < FPS_CAPTURE_FRAMES_COUNT; i++)
|
||||||
|
history[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (fpsFrame == 0) return 0;
|
if (fpsFrame == 0) return 0;
|
||||||
|
|
||||||
if ((GetTime() - last) > FPS_STEP)
|
if ((GetTime() - last) > FPS_STEP)
|
||||||
|
|||||||
Reference in New Issue
Block a user