【问题标题】:How can I fix this Segmentation fault using SFML?如何使用 SFML 修复此分段错误?
【发布时间】:2015-07-12 13:02:42
【问题描述】:

运行此代码时出现分段错误错误 该错误是在自定义对象的绘制函数处触发的。 我相信它与窗口的地址有关。

GameObject *obj = new Dummy;

//game loop
while (window.isOpen())
{
    sf::Event event;
    while (window.pollEvent(event))
    {
        if (event.type == sf::Event::Closed)
            window.close();
    }
    window.clear();
    obj->draw(window);
    window.display();
}

return 0;

}

我粘贴了整个代码here

【问题讨论】:

    标签: c++ segmentation-fault sfml


    【解决方案1】:

    我修好了。 问题是我丢失了纹理,因为它不是用 new 创建的,所以在构造函数创建它之后,精灵就被放逐了。

    【讨论】:

      猜你喜欢
      • 2022-11-21
      • 2020-02-22
      • 2012-09-04
      • 1970-01-01
      • 2016-04-07
      • 1970-01-01
      • 1970-01-01
      • 2017-06-04
      相关资源
      最近更新 更多