From d1c9afd1d8ae4ae3e075b117fff7a5a77f3c4d60 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 5 Mar 2017 19:17:00 +0100 Subject: Work on timming functions... It seems Sleep() behaves weird on my computer, disabled by default returning to the busy wait loop... also re-implemented DrawFPS() to avoid frame blitting... --- src/text.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/text.c') diff --git a/src/text.c b/src/text.c index 6f18b391..18ebf482 100644 --- a/src/text.c +++ b/src/text.c @@ -531,8 +531,22 @@ Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, float fontSize, i // NOTE: Uses default font void DrawFPS(int posX, int posY) { + // NOTE: We are rendering fps every second for better viewing on high framerates + + static int fps = 0; + static int counter = 0; + static int refreshRate = 20; + + if (counter < refreshRate) counter++; + else + { + fps = GetFPS(); + refreshRate = fps; + counter = 0; + } + // NOTE: We have rounding errors every frame, so it oscillates a lot - DrawText(FormatText("%2i FPS", GetFPS()), posX, posY, 20, LIME); + DrawText(FormatText("%2i FPS", fps), posX, posY, 20, LIME); } //---------------------------------------------------------------------------------- -- cgit v1.2.3