c++ - SFML 2.4.2 不在 VS 2017 社区中绘制

标签 c++ visual-studio-2017 sfml

我遇到了一些我找不到解决方案的愚蠢问题。我正在使用 visual studio 2017 社区,我想创建一个带有黑色背景和蓝色圆圈的窗口。我正在使用 C++ 和 SFML 2.4.2。目前它只显示一个白色的空窗口。

//Main Function
int main() {

    sf::RenderWindow window(sf::VideoMode(800, 800), "Window Name");    

    sf::CircleShape creature;
    creature.setRadius(50);
    creature.setFillColor(sf::Color::Blue);
    creature.setPosition(400, 400);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
        window.clear();
        window.draw(creature);
        cout << "Creature draws";
        window.display();
    }    
    system("PAUSE");
    return 0;
}

没有任何错误显示,我检查了几次,我正确地包含了 SFML。很抱歉提出这样的问题,但我很乐意提供帮助。

最佳答案

window.display() 

这应该在 while 循环内,否则 sfml 在您关闭窗口之前不会显示任何内容。

关于c++ - SFML 2.4.2 不在 VS 2017 社区中绘制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47530216/

相关文章:

c++ - 如何将 UTF-8 文本转换为用于 SFML 的 wstring?

汇编编程 - WinAsm 与 Visual Studio 2017

c++ - 莱曼算法没有意义

C++输入和输出管道到外部程序

c++ - 尽管使用了 BOOST_NO_CXX11_SCOPED_ENUMS,但 boost::filesystem 出现 undefined reference 错误

git - 无法推送 git,visual studio。 Git 因 fatal error 而失败。致命的 : HttpRequestException encountered

c++ - Visual Studio 远程调试 Makefile 项目的远程输出路径错误

c++ - 在类(class)中如何访问类(class)成员指向的地址?

c++ - 使用 Composite Pattern 制作游戏菜单

c++ - 从另一个进程中的内存执行一个进程?