2
« 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:
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.