c++ - SFML: Vector2<double> 无法编译

标签 c++ templates sfml

我有无法编译的代码。如果我更换 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 构造函数不采用 double vector ,仅采用浮点 vector 。查看documentation .

关于c++ - SFML: Vector2<double> 无法编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63325596/

相关文章:

c++ - ReadFile() 说失败,但错误代码是 ERROR_SUCCESS

c++ - 检测类型是否为函数

c++ - 为什么该代码不绘制 Sprite C++ SFML

c++ - 在 C++ 的 SFML 中居中​​形状/对象

c++ - 在 C++ 中使用 SFML 将数据包数据复制到另一个数据包

c++ - 在不提供定义的情况下覆盖函数有什么意义?

c# - 在 C++ 中实现接口(interface)

c++ - 重置嵌入式 ruby​​ 解释器的状态

具有 const 类型或简单类型参数的方法的 C++ 模板函数

c++ - 带有自定义消息的基于模板的编译时断言只能在某些编译器中编译