SFML community forums
General => General discussions => Topic started by: keyforge on June 23, 2011, 03:07:54 am
-
Hello, I'm only getting like 16 FPS with this game loop. When I move the render outside of the loop I'm getting like 800 FPS. Is this an issue with my code or SFML 2? I have SetFramerateLimit() at 60 and my computer is pretty new.
When I cout 1.f / myWindow.GetFrameTime() it says like 0.0######.
When I cout myWindow.GetFrameTime() it says 16 or 15.
Help please?
void Game::Tick() {
while(myWindow.IsOpened() && myRunning) {
sf::Uint32 elapsedTime = myLoopClock.GetElapsedTime();
myLoopClock.Reset();
while(elapsedTime > myLoopClock.GetElapsedTime()) {
sf::Event tmpEvent;
while(myWindow.PollEvent(tmpEvent)) {
HandleEvents(tmpEvent);
}
}
myStateManager.Update();
myStateManager.Render();
myWindow.Display();
myStateManager.Cleanup();
std::cout << 1.f / myWindow.GetFrameTime() << std::endl;
}
}
-
I tried switching back to SFML-1.6 and the FPS was fine. Has their been an SFML2 update in the past month that broke it and / or fixed it?
-
When I cout 1.f / myWindow.GetFrameTime() it says like 0.0######.
When I cout myWindow.GetFrameTime() it says 16 or 15.
Time is in milliseconds now.
-
So it is now 15 frames per milisecond? That is way off the 60 FPS.... :roll:
15 FPmS -> 15000 FPS
60 FPS -> 0,06 FPmS
FPS -> divide by 1000 -> FPmS
-
No, it's (1 / 16 ms) = (1 / 0.016 s) = 60 FPS.
-
Ok, I feel stupid now...
So how would I go about getting the true FPS? With Vertical Sync on I'm only getting 30 FPS with SFML 1.6, and that's pretty bad because I have a mobility radeon 4100 and it's pretty fast. Could my driver be out of date?
And is 1.f / (1.f / myWindow.GetFrameTime()) the true fps?
-
And is 1.f / (1.f / myWindow.GetFrameTime()) the true fps?
No, 1 / (1/x) is x itself. The frame time is not same as the number of frames per second.
FPS can be computed like this:
1.f / (frametime / 1000.f)
1000.f / frametime