【发布时间】:2014-10-10 22:23:24
【问题描述】:
我是一名初级 C++ 程序员,目前正在使用 SFML。我将 Eclipse CDT 与 MinGW GCC 一起使用,我正在尝试使用在 http://sfml-dev.org/tutorials/2.1/start-cb.php 找到的源代码创建一个基本窗口。我把代码放进去,显然它不起作用。我尝试包含库、链接器路径、包含路径、包含文件和所有内容,但它似乎对我不起作用。
代码:
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include <SFML\System.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Application");
sf::CircleShape shape;
shape.setRadius(40.f);
shape.setPosition(100.f, 100.f);
shape.setFillColor(sf::Color::Cyan);
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();
}
}
我的控制台出现错误,例如“'window' not defined in this scope”、“'shape' not defined in this scope”、“expected ; before 'shape'”等。
有谁知道为什么,谁能帮帮我?
【问题讨论】:
-
信息不足。如果您遇到错误,不要只是描述它,提供完整的信息......尤其是“不起作用”不是问题描述。最后,您需要实际提供有关您使用的设置的信息。