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

Author Topic: GetFrameTime bug?  (Read 2152 times)

0 Members and 2 Guests are viewing this topic.

BMCha

  • Newbie
  • *
  • Posts: 3
    • View Profile
GetFrameTime bug?
« on: July 21, 2009, 02:27:10 am »
EDIT: After a test, this topic has been changed.

If I run my game with frame limiting enabled, It correctly reports 60 fps. However, if I run with vsync, it runs at 60, but reports 30 fps when I move my mouse, sometimes showing very large numbers around 10,000. Commenting out my event loop fixes the problem.

Event loop below:
Code: [Select]

while (App.GetEvent(Event))
        {
            // Window closed
            if (Event.Type == sf::Event::Closed)
                App.Close();

            if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Space && jumping==false) {
                body->ApplyImpulse(b2Vec2(0.f,-80.f), body->GetPosition());
                jumping=true;
            }

            if (Event.Type == sf::Event::MouseButtonPressed && Event.MouseButton.Button == sf::Mouse::Left) {
                //calculate starting pos and vector
                sf::Vector2f P2MVec;
                sf::Vector2f MousePos=App.ConvertCoords(Input.GetMouseX(), Input.GetMouseY(), &MainView);
                P2MVec.x=MousePos.x-body->GetPosition().x;
                P2MVec.y=MousePos.y-body->GetPosition().y;
                P2MVec=VecTools::Normalize(P2MVec);
                //create grenade
                Grenade * boop=new Grenade (body->GetPosition().x,body->GetPosition().y,P2MVec.x,P2MVec.y,1.f);
                UpdateList.push_back(boop);
            }
        }







OLD TOPIC:
If I have vsync enabled in my program, it runs fine, but whenever I move the mouse the fps drops to 30 from 60. If I disable vsync and instead limit the framerate to 30, there is not fps drop. In an attempt to find the cause, I commented out my event loop, and there was no drop. Perhaps it has something to do with mousemove events? This isn't a game-breaking bug, but it would be nice to be able to use vsync.

klusark

  • Newbie
  • *
  • Posts: 45
    • View Profile
GetFrameTime bug?
« Reply #1 on: July 21, 2009, 02:28:33 am »
What kind of frame rates are you getting without vsync? What is happening in your event loop?

BMCha

  • Newbie
  • *
  • Posts: 3
    • View Profile
GetFrameTime bug?
« Reply #2 on: July 21, 2009, 07:31:16 am »
Without SetFramerateLimit, I get fps around 2200. Also, I just ran it with fraps, and it reported 60 fps instead of the 30 that my fps counter reported when I moved the mouse with vsync on. Also, when my fps goes down to 30, it sometimes shows random high numbers(usually > 10,000). I'm now thinking that it has something to do with the getframetime function I'm using for fps calculation.

 

anything