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...
This commit is contained in:
raysan5 2017-03-05 19:17:00 +01:00
parent 203d1a154e
commit d1c9afd1d8
3 changed files with 58 additions and 38 deletions

View file

@ -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);
}
//----------------------------------------------------------------------------------