SFML community forums

Help => Graphics => Topic started by: Phictus on June 21, 2021, 01:12:31 pm

Title: weird error with texture loading
Post by: Phictus on June 21, 2021, 01:12:31 pm
this is the code:
sf::Texture texture;
if (!texture.loadFromFile("assets/textures/spaceship.png"))
    __debugbreak();
m_Sprite.setTexture(texture);
 
but i get this error in the console: "Failed to load image "". Reason: Unable to open file"
it doesn't even say the texture path that it tried to open so i don't think that the image is the problem.
Title: Re: weird error with texture loading
Post by: Stauricus on June 21, 2021, 01:19:33 pm
on the other hand, i think the image is exactly the problem  ;D
make sure it is not corrupted (can you open it with an image viewer, for example?)
and how is your project folder (specifically, the png folder)? personally i like screenshots to help finding the problem.
if you're using Linux, you can try adding " ./ " at the image path, altough i don't think this is going to solve the problem.
"./assets/textures/spaceship.png"
Title: Re: weird error with texture loading
Post by: eXpl0it3r on June 21, 2021, 03:40:51 pm
Or you might be linking release libraries in debug mode.
Make sure you use debug libraries in debug mode and release libraries in release mode.