【问题标题】:why loadFromFile produces access violation when reading location?为什么 loadFromFile 在读取位置时会产生访问冲突?
【发布时间】:2021-04-30 16:36:23
【问题描述】:

我是 c ++ / SFML 的新手,我不知道为什么我的程序无法加载纹理,我尝试将图像放在我的项目文件夹和调试文件夹中,但没有成功。

代码:

int main() {
sf::RenderWindow window(VideoMode(600,600),"Window");

sf::Event event;

sf::Texture textura;
textura.loadFromFile("icono.png");

sf::Sprite sprite1(textura);

while (window.isOpen()) {
    while (window.pollEvent(event)) {
        if (event.type== sf::Event::EventType::Closed) {
            window.close();
        }
    }
    window.clear();
    window.draw(sprite1);
    window.display();
}

}

错误是“textura.loadFromFile("icono.png");”行中的“TestSFML.exe 中 0x5F6D3647 (vcruntime140.dll) 处的未处理异常:0xC0000005:读取位置 0x00701000 时发生访问冲突”

【问题讨论】:

    标签: c++ sfml


    【解决方案1】:

    我找到了答案并分享它以防万一。可能的解决方案是在“附加依赖项”中添加SFML调试库,库是“sfml-graphics-d.lib”和“sfml-system-d.lib”。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-24
      • 1970-01-01
      • 2021-12-31
      • 2016-05-28
      • 2017-01-09
      • 2014-11-09
      • 1970-01-01
      相关资源
      最近更新 更多