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

Author Topic: Mouse movement causing framerate drop  (Read 916 times)

0 Members and 1 Guest are viewing this topic.

RockAFellaeo

  • Newbie
  • *
  • Posts: 1
    • View Profile
Mouse movement causing framerate drop
« on: January 18, 2013, 02:50:58 pm »
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();
        }

}

 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10835
    • View Profile
    • development blog
    • Email
Re: Mouse movement causing framerate drop
« Reply #1 on: January 18, 2013, 03:23:56 pm »
Yeah it's a 'known' problem with some gaming mouses, I don't know though, why it only happens with some, because I'm using a ROCCAT Kone XTD with a polling rate of 1000 MHz and don't have any problems, even with a DPI of 8200 I get the framerates below:
Framerate:1695.57
Framerate:1739.74
Framerate:1742.47
Framerate:1743.78
Framerate:1742.52
Framerate:1717.38
Framerate:1728.35
Framerate:1738.87
Framerate:1745.73
Framerate:1747.2
Framerate:1738.73
Framerate:1742.04
Framerate:1743.3
Framerate:1748.61
Framerate:1739.68
Framerate:1737.61

To fix the problem on your end, I think you can try to modify SFML's source, so it doesn't process the MouseMoved event...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/