For the life of me I can't figure out what the issue is. I've done plenty of searches, but I think I might be missing something since I now have tunnel vision. I'm using SFML 2.1 for this.
Here's the minimal example with code from a search:
int main() {
sf::RenderWindow Window(sf::VideoMode(100, 100, 32), "Test");
Window.setFrameLimit(60);
sf::Clock clock;
float lastTime = 0;
while (Window.isOpen()) {
float currentTime = clock.restart().asSeconds();
float fps = 1.f / (currentTime - lastTime);
lastTime = currentTime;
std::cout << fps << std::endl;
}
return 0;
}
Console:
-327.225
32258.1
23255.8
-1002
And so on with various numbers
FPS are the inverse of the (mean) frame length.
Your currentTime variable is essentially the time elapsed since lastFrame, so you don't need a lastTime variable to compute your FPS:float currentTime = clock.restart().asSeconds();
float fps = 1.f / currentTime;
You can also compute your FPS with the time elapsed since the clock started, you would need a lastTime variable and you shouldn't restart the clock:float currentTime = clock.asSeconds();
float fps = 1.f / (currentTime - lastTime);
lastTime = currentTime;
FPS are the inverse of the (mean) frame length.
Your currentTime variable is essentially the time elapsed since lastFrame, so you don't need a lastTime variable to compute your FPS:float currentTime = clock.restart().asSeconds();
float fps = 1.f / currentTime;
You can also compute your FPS with the time elapsed since the clock started, you would need a lastTime variable and you shouldn't restart the clock:float currentTime = clock.asSeconds();
float fps = 1.f / (currentTime - lastTime);
lastTime = currentTime;
Oh I see. Thank you G.!
And thanks to eXpl0it3r his post led me to solve the problem in my up-scaled project. My "while" loop wasn't calling window.display() every loop therefore I had huge numbers for the FPS.