SFML RenderWindow taking a long time to open a window

青春壹個敷衍的年華 提交于 2019-12-24 00:08:33

问题


I know this is essentially a duplicate, but this wasn't ever answered. I'd like to mention that I have followed the tutorial for using SFML along with Visual Studio, and I'm running a 64-bit project with 64-bit SFML. The window loaded instantly a few times, and now consistently takes 40 seconds to open on new builds/debugs. I also have the downloading of debug symbols off. My graphics drivers are up to date and my HDD is fine. This is the code:

 #include <SFML/Graphics.hpp>

int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");//This one
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);

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

    window.clear();
    window.draw(shape);
    window.display();
}

return 0;
}

Everything runs at normal speed, except for RenderWindow, which again, takes exactly 40 seconds every time. Does anyone know how I could fix this? I've been having this issue for a few weeks now.

e: Could it be my CPU? It's not the best but I can still run most games just fine as I have a 1050ti. My current CPU is an i5-2500k, although I believe I got the same issue on an A10-5800k.


回答1:


An contributor on the SFML discord helped me source the issue by going through and showing me how to look through the callstack, and it turned out that the freeze was when polling for dx input, and after a little bit of experimenting we figured out my k55 keyboard was to blame. I'll try to find a fix later tonight, but in short term situations unplugging it makes everything work fine.



来源:https://stackoverflow.com/questions/53017551/sfml-renderwindow-taking-a-long-time-to-open-a-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!