summaryrefslogtreecommitdiffhomepage
path: root/src/text.c
diff options
context:
space:
mode:
authorraysan5 <[email protected]>2017-03-05 19:17:00 +0100
committerraysan5 <[email protected]>2017-03-05 19:17:00 +0100
commitd1c9afd1d8ae4ae3e075b117fff7a5a77f3c4d60 (patch)
treebf02b380f45b5f48b4934ae68cf759fd943c81be /src/text.c
parent203d1a154eb5b78fc5f56e9dead04c3a89bcd39e (diff)
downloadraylib-d1c9afd1d8ae4ae3e075b117fff7a5a77f3c4d60.tar.gz
raylib-d1c9afd1d8ae4ae3e075b117fff7a5a77f3c4d60.zip
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...
Diffstat (limited to 'src/text.c')
-rw-r--r--src/text.c16
1 files changed, 15 insertions, 1 deletions
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);
}
//----------------------------------------------------------------------------------