From 9c057b834f79bd4b481f566329e2c3a0d98a8772 Mon Sep 17 00:00:00 2001 From: Umut Alev Date: Mon, 4 Sep 2023 22:50:18 -0700 Subject: [PATCH] DrawFPS - acquire FPS only once per call --- src/rtext.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/rtext.c b/src/rtext.c index 5ca97d06d..66ccc78ca 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1069,13 +1069,14 @@ bool ExportFontAsCode(Font font, const char *fileName) // NOTE: Uses default font void DrawFPS(int posX, int posY) { - Color color = LIME; // Good FPS - int fps = GetFPS(); + const int fps = GetFPS(); - if ((fps < 30) && (fps >= 15)) color = ORANGE; // Warning FPS - else if (fps < 15) color = RED; // Low FPS + Color color = + fps < 15 ? RED : // Low FPS + fps < 30 ? ORANGE : // Warning FPS + LIME; // Good FPS - DrawText(TextFormat("%2i FPS", GetFPS()), posX, posY, 20, color); + DrawText(TextFormat("%2i FPS", fps), posX, posY, 20, color); } // Draw text (using default font)