c++ - SFML:矢量 2无法编译
问题描述
我有无法编译的代码。如果我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>)’
解决方案
sf::Vertex
构造函数不接受双向量,只接受浮点向量。请参阅文档。
推荐阅读
- assembly - 在汇编 x86 中乘以 3 个数字
- python - 如何在 Python 中将 CSV 列数据拆分为两列
- bash - 使用 -ldflags 传递给 Go 编译器的字符串中的 Shell 变量未展开
- hosting - 我应该在godaddy 或hoster 中设置子域吗?域名从 godaddy 指向托管商
- c# - 异步填充字典
- python - 用于在屏幕上搜索特定单词的代码 [PYTHON]
- java - 如何验证列表元素是否与另一个列表的顺序相同?
- android - Android:在 eink 设备上使用 fb0 绘图
- java - 在 springBoot 上设计一个 MongoDB 模式
- excel - 在 VBA 中清除组合框的内容