SFML RenderWindow需要很长时间才能打开一个窗口 [英] SFML RenderWindow taking a long time to open a window

查看:82
本文介绍了SFML RenderWindow需要很长时间才能打开一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这本质上是重复的,但从来没有回答过.我想提一下,我已经遵循教程为了将 SFML 与 Visual Studio 一起使用,我正在使用 64 位 SFML 运行 64 位项目.窗口会立即加载几次,现在在新构建/调试时始终需要 40 秒才能打开.我也关闭了调试符号的下载.我的图形驱动程序是最新的,我的硬盘很好.这是代码:

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;
}

一切都以正常速度运行,但 RenderWindow 除外,它每次都需要 40 秒.有谁知道我该如何解决这个问题?这个问题我已经有几个星期了.

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:会不会是我的 CPU?这不是最好的,但我仍然可以运行大多数游戏,因为我有 1050ti.我目前的 CPU 是 i5-2500k,但我相信我在 A10-5800k 上遇到了同样的问题.

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.

推荐答案

在您采用以下解决方案之前,请尝试更新您的键盘固件!您很可能使用的是 Corsair 键盘,因此请下载 Corsair 的 iCue 并更新您的键盘司机.这很可能会解决这些问题.如果它不起作用,请尝试以下操作:

Before you resort to the solution below, try updating your keyboards firmware! You're most likely using a Corsair keyboard, so download Corsair's iCue and update your keyboard drivers. This will most likely fix these issues. If it didn't work, then try the following:

由于 OP 没有进一步回复,我尝试自己寻找解决方法,因为此问题在 2020 年仍然存在.此解决方法需要您自己编译库.所以下载源代码并更改以下内容:

Since OP didn't reply any further, I tried to find a workaround myself, as this issue still exists in 2020. This workaround requires you to compile the libraries yourself. So download the source code and change the following:

  • WindowImpl.cpp 中,导航到函数 WindowImp::WindowImp 并注释掉整个函数体.
  • WindowImpl.cpp 中,导航到 WindowImp::popEvent 并注释掉对 processJoystickEvents
  • 的调用
  • In WindowImpl.cpp, navigate to the function WindowImp::WindowImp and comment out the whole function body.
  • In WindowImpl.cpp, navigate to WindowImp::popEvent and comment out the call to processJoystickEvents

只要您不使用 SFML 的操纵杆部分,这应该可以正常工作.

As long as you don't use the Joystick part of SFML this should work without issues.

这篇关于SFML RenderWindow需要很长时间才能打开一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆