[英]0xC0000005: Access violation reading location
Hi i am new to using SFML library, i want to show an image using SFML library but getting "0xC0000005: Access violation reading location" error on following code: I have added the png file in the project location but still the code doesn't work嗨,我是使用 SFML 库的新手,我想使用 SFML 库显示图像,但在以下代码中出现“0xC0000005:访问冲突读取位置”错误:我在项目位置添加了 png 文件,但代码仍然没有工作
#include <SFML/Graphics.hpp>
#include<iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::Texture t1;
std::cout << "load enemy texture" << std::endl;
//system("dir");
if (!t1.loadFromFile("test.jpg")) {
std::cout << "Could not load enemy texture" << std::endl;
return 0;
}
sf::Sprite enemySprite;
enemySprite.setTexture(t1);
enemySprite.setPosition(sf::Vector2f(100, 100));
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(enemySprite);
window.display();
}
return 0;
}
as link suggested by @Yksisarvinen in the comment switching the configuration to Release suddenly made everything work.正如@Yksisarvinen 在评论中建议的链接将配置切换到 Release 突然使一切正常。
To get the debug configuration to work, I just had to change the names from sfml-graphics.lib to sfml-graphics-d.lib (and so on).为了使调试配置工作,我只需要将名称从 sfml-graphics.lib 更改为 sfml-graphics-d.lib(等等)。
Thank you guys.谢谢你们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.