我有一段代码编译不了。如果我将 sf::Vector2<double>
替换为 sf::Vector2f
,它就能正常工作。我已经尝试过使用 typedef
,但没有任何改变。
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::Vertex line[] =
{
sf::Vertex(sf::Vector2<double>(10.0, 10.0)),
sf::Vertex(sf::Vector2<double>(150.0, 150.0))
};
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{
window.close();
}
}
window.clear();
window.draw(line, 2, sf::Lines);
window.display();
}
return 0;
}
第一个错误:
test.cpp: In function ‘int main()’:
test.cpp:9:47: error: no matching function for call to ‘sf::Vertex::Vertex(sf::Vector2<double>)’
Vector2
是模板呢?现在看起来好像没用。有没有办法使用double
? - MangodileWindow::setPosition()
采用Vector2i
,而Window::setSize()
采用Vector2u
。对于绘制线条之类的事情,双精度并没有太多意义。 - ypnos