Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: loadfromfile failing to load an image  (Read 1548 times)

0 Members and 1 Guest are viewing this topic.

tea022

  • Newbie
  • *
  • Posts: 1
    • View Profile
loadfromfile failing to load an image
« 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.

Mortal

  • Sr. Member
  • ****
  • Posts: 284
    • View Profile
Re: loadfromfile failing to load an image
« Reply #1 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: loadfromfile failing to load an image
« Reply #2 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*