Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Only getting 16 FPS?  (Read 3437 times)

0 Members and 1 Guest are viewing this topic.

keyforge

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Only getting 16 FPS?
« 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?

Code: [Select]
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;
}
}
Need a place to upload your code, files or screenshots? Use SFML Uploads!

keyforge

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Only getting 16 FPS?
« Reply #1 on: June 23, 2011, 05:32:55 am »
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?
Need a place to upload your code, files or screenshots? Use SFML Uploads!

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Only getting 16 FPS?
« Reply #2 on: June 23, 2011, 07:34:51 am »
Quote
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.
Laurent Gomila - SFML developer

Cuban-Pete

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Only getting 16 FPS?
« Reply #3 on: June 23, 2011, 07:51:17 am »
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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Only getting 16 FPS?
« Reply #4 on: June 23, 2011, 08:14:08 am »
No, it's (1 / 16 ms) = (1 / 0.016 s) = 60 FPS.
Laurent Gomila - SFML developer

keyforge

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Only getting 16 FPS?
« Reply #5 on: June 23, 2011, 09:12:11 pm »
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?
Need a place to upload your code, files or screenshots? Use SFML Uploads!

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Only getting 16 FPS?
« Reply #6 on: June 23, 2011, 09:26:21 pm »
Quote from: "keyforge"
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:
Code: [Select]
1.f / (frametime / 1000.f)
1000.f / frametime
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything