I was experiencing massive framerate drops when moving my mouse (basically my mainloop was in a complete standstill as long as I was continually moving my mouse) but figured out a way to fix it.
The problem was, that my mouse was set to refresh with 500Hz. After setting the refresh rate to 125Hz, the problem disappeared.
I'm using SFML 2.0 and a Razer Imperator Mouse. Is there some way to work around this or do I have to tell my users to set their mouse refresh rate to 125 Hz?
This is the code I used to further investigate the problem:
#include <SFML\Graphics.hpp>
#include <iostream>
int main()
{
sf::VideoMode vMode(800,600);
sf::RenderWindow window(vMode, "SFML-Tutorial");
sf::Clock frameRateClock;
int loopCount = 0;
sf::Time addedTime;
while(window.isOpen())
{
sf::Event Event;
while(window.pollEvent(Event))
{
switch(Event.type)
{
case sf::Event::Closed:
window.close();
break;
default:
break;
}
}
addedTime += frameRateClock.restart();
loopCount += 1;
if(addedTime.asSeconds() >= 2)
{
std::cout << "Framerate:" << loopCount/addedTime.asSeconds() << std::endl;
addedTime = addedTime.Zero;
loopCount = 0;
}
window.clear(sf::Color(0,255,255));
window.display();
}
}