diff options
| author | raysan5 <[email protected]> | 2017-03-05 19:17:00 +0100 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2017-03-05 19:17:00 +0100 |
| commit | d1c9afd1d8ae4ae3e075b117fff7a5a77f3c4d60 (patch) | |
| tree | bf02b380f45b5f48b4934ae68cf759fd943c81be /src/text.c | |
| parent | 203d1a154eb5b78fc5f56e9dead04c3a89bcd39e (diff) | |
| download | raylib-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.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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); } //---------------------------------------------------------------------------------- |
