【问题标题】:Error when trying to use SFLM Vertex: "Vertex is not a member of sf"尝试使用 SFLM Vertex 时出错:“Vertex 不是 sf 的成员”
【发布时间】:2018-04-12 17:58:18
【问题描述】:

我正在使用 SFML,我一直在尝试使用顶点数组,但是每当我写类似的东西时

sf::Vertex vertex;

并编译,它给了我一个错误提示

'Vertex' 不是 sf 的成员

#include<iostream>
#include<SFML/Graphics.hpp>
#include<Vertex.hpp>

int main(){
  sf::RenderWindow window(sf::VideoMode(200,200), "SFML WORKS");
  sf::CircleShape shape(100.f);
  shape.setFillColor(sf::Color::Green);


  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();
  }
  sf::Vertex vertex;

  return 0;
}

它现在也给我一个错误说:

"SFMLtest.cpp:3:9: fatal error: Vertex.hpp: No such file or directory
 #include<Vertex.hpp>"

【问题讨论】:

  • 显示代码。在没有任何说明您如何到达那里的情况下发布告诉我们您遇到的错误是没有用的;它只会导致无用的猜测。但请注意,请确保您只包含正确的标题...
  • One requirement is #include &lt;Vertex.hpp&gt;。你的代码中有这个吗?
  • 阅读帮助中心以了解如何提问。不应将基本信息倾倒在 cmets 中。评论仅用于额外讨论。 Edit您的帖子以包含读者评估它所需的所有信息。
  • 感谢您的反馈。我已将代码添加到帖子中。
  • 转到“如何为初学者编译代码”教程中的下一步:告诉编译器在哪里可以找到包含。

标签: c++ sfml


【解决方案1】:
#include<Vertex.hpp>

上面的行应该是

#include <SFML/Graphics/Vertex.hpp>

但是你根本不需要它,因为#include &lt;SFML/Graphics.hpp&gt; 已经为你做了这个。因此,只需完全删除包含顶点线即可。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-02
    • 2022-09-27
    • 1970-01-01
    相关资源
    最近更新 更多