This forum does support Code tags, please use them
You could do something simple like
sf::Time interval = sf::seconds(1);
float fpsCounter = 0;
while(window.isOpen)
{
fpsCounter ++;
if(fpsclock.getElaspedTime() >= interval)
{
fpsLog << fpsCounter / interval.asSeconds();
fpsCounter = 0;
fpsclock.restart();
}
}
I just wrote it without testing, but it should be accurate enough (+- 1Frame) and very short to implement.
Also keep in mind that FPS is not linear and does not show peaks in frametime (if you measure a whole second into one value, as in the example). If your game does not feel smooth but still has >= 60FPS you should look at frametime variation.
P.S. fpsclock.restart() does return the elapsedTime before restarting, so your .asSeconds() does nothing
. But you could write instead of
FPSTimer = fpsclock.getElapsedTime();
//...
fpsclock.restart().asSeconds();
simply write:
FPSTimer = fpsclock.restart()
Which does exactly the same
AlexAUT