我遇到了一些我找不到解决方案的愚蠢问题。我正在使用 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/