【问题标题】:SFML RenderWindow Odd CharactersSFML RenderWindow 奇数字符
【发布时间】:2011-10-28 08:20:45
【问题描述】:

所以我试图让 SFML 与 Visual C++ 2010 一起工作,它现在会打开窗口,但它看起来像这样。

当您尝试移动或关闭它时,该窗口也没有响应。 这是我的代码:

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

int main()
{
    // Create the main window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");

    while (true)
    {
        App.Clear();


        App.Display();
    }

    return EXIT_SUCCESS;
}

【问题讨论】:

    标签: c++ sfml


    【解决方案1】:

    您必须每帧轮询事件以让窗口响应操作系统。否则,您将不会移动或关闭它。

    #include <SFML/Graphics.hpp>
    int main()
    {
        sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Window");
        while (App.IsOpened())
        {
            App.Clear();
            sf::Event event;
            while (App.PollEvent(event))
            {
                if (event.Type == sf::Event::Closed)
                    App.Close();
            }
            App.Display();
        }
        return EXIT_SUCCESS;
    }
    

    如果您使用 SFML 1.6,请将 PollEvent 更改为 GetEvent。阅读文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-17
      • 1970-01-01
      • 1970-01-01
      • 2015-02-05
      • 2016-04-23
      • 1970-01-01
      • 1970-01-01
      • 2017-05-15
      相关资源
      最近更新 更多