SFML community forums

Help => Graphics => Topic started by: tea022 on January 24, 2020, 04:55:08 pm

Title: loadfromfile failing to load an image
Post by: tea022 on January 24, 2020, 04:55:08 pm
Hello!
I'm just starting to learn SFML, but i've stumbled upon a problem that my sprites do not appear in a created window. i thought that this may be because images are just not downloaded from the file and sprites remail blank. Here's how i was doing it.
RenderWindow window(sf::VideoMode(640, 480), "Test");

Texture t;
t.loadFromFile("file_name.png");       

Sprite s;
s.setTexture(t);
s.setPosition(200, 200);

window.draw(s);
window.display();
 
i've tried to call the file by it's full path, but it didn't help, so now i'm wondering what the problem could be.
Title: Re: loadfromfile failing to load an image
Post by: Mortal on January 24, 2020, 07:24:05 pm
"loadFromFile()" usually print an error message on console screen if it can't open the file. check it if there is a message. if not then make complete and minimal example that produce same error.
Title: Re: loadfromfile failing to load an image
Post by: Hapax on January 29, 2020, 09:44:55 pm
loadFromFile also return a boolean depending on its success. You should check this to see if the loading is the problem or if it could be elsewhere.