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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - szpaq234

Pages: [1]
1
General / window.poll() lags on my desktop PC
« on: April 09, 2016, 05:06:38 am »
window.poll() sometimes gets stuck. What exactly happens is program spins in the while loop and occasionally window.poll() takes up to 7s !!! to execute. Below is minimal code that causes the problem and as you can see, there's nothing that would interfere with the window even remotely. It seems that sfml doesn't like my PC. This happens only on my desktop running Win10. It work normally on my laptop that also runs win10. Any thoughts ?

I did a quick test, no event is actually being caught during the lag.

#include <SFML/Graphics.hpp>
#include <chrono>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");
    while (window.isOpen())
    {
        std::chrono::milliseconds t1 = std::chrono::duration_cast<std::chrono::milliseconds>
            (std::chrono::system_clock::now().time_since_epoch());

        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        std::chrono::milliseconds t2 = std::chrono::duration_cast<std::chrono::milliseconds>
            (std::chrono::system_clock::now().time_since_epoch());
        int dur = (int)((t2 - t1).count());
        if (dur > 20)
            printf("%d\n", dur);

        window.clear(sf::Color::Black);
        window.display();
    }

    return 0;
}
 

Pages: [1]