I have the following code:
#include <SFML\Graphics.hpp>
#include <iostream>
int main(int argc, char* argv[])
{
sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Render");
sf::Image image;
sf::Texture texture;
sf::Sprite sprite;
image.loadFromFile("D:/Project/Sprites/bt1.png");
texture.loadFromImage(image);
sprite.setTexture(texture);
sprite.setPosition(100.0f, 100.0f);
sf::Event event;
while (window.isOpen())
{
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(sprite);
window.display();
}
return 0;
}
It's very simple, but it didn't work.
I tried using different kinds of paths:
D:/Project/CPP/Game_Engine/Debug/sprites/first.bmp
D:\\Project\\CPP\\Game_Engine\\Debug\\sprites\\first.bmp
d:\\Project\\CPP\\Game_Engine\\Debug\\sprites\\first.bmp
Then I tried using different files:
D:/Project/Sprites/bt.png
D:/Project/Sprites/anim.bmp
D:/Project/Sprites/boy.jpg
Compiler indicates at the following line:
image.loadFromFile("D:/Project/Sprites/bt1.png");
More precisely, Program crashes on this line.
My configuration is the following:
Error/crash message is the following:
Необработанное исключение по адресу 0x5007DEF8 (msvcr110.dll) в SFML_ERROR.exe: 0xC0000005: нарушение прав доступа при чтении по адресу 0x03BC1000.
Translation is the following:
Unhandled exception at 0x5007DEF8 (msvcr110.dll) in SFML_ERROR.exe: 0xC0000005: Access violation reading on Address 0x03BC1000.
My problem is mixed Debug/Release, I used sfml-window.lib
, but I have to use `sfml-window-d.lib'. I can't use the debug SFML library because I am using VC++ 2013 (v120, but SFML requires v110). So, I recompiled the official library and it worked!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With