DrawFPS - acquire FPS only once per call

This commit is contained in:
Umut Alev 2023-09-04 22:50:18 -07:00
parent c104a97590
commit 9c057b834f

View File

@ -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)