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

Author Topic: Texture "loadFromFile" does not work  (Read 1342 times)

0 Members and 1 Guest are viewing this topic.

Harald15

  • Newbie
  • *
  • Posts: 2
    • View Profile
Texture "loadFromFile" does not work
« on: April 09, 2019, 05:41:32 pm »
Hello, I've been trying to get an example to work.
This is the code I currently have:

#include <SFML/Graphics.hpp>
#include <time.h>
using namespace sf;

int main()
{
        RenderWindow window(VideoMode(320, 480), "The Game!");

        Texture t;
        t.loadFromFile("images/tiles.png");

        while (window.isOpen())
        {
                Event e;
                while (window.pollEvent(e))
                {
                        if (e.type == Event::Closed)
                                window.close();
                }
                window.clear(Color::White);
                window.display();
        }

        return 0;
}

However, the "loadFromFile" does not work. (If I comment that line out, everything's fine)
I checked the current working directory, and it is set to the project directory.
I tried setting it to the specific folder, but it still doesn't work.
I am using Visual Studio 2017.
Sadly even the command line only gives me some garbled text, so I have no idea what is even going wrong. (See the attachment)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Texture "loadFromFile" does not work
« Reply #1 on: April 09, 2019, 06:09:31 pm »
Make sure that you're not using release SFML libraries in a debug build.
Laurent Gomila - SFML developer

Harald15

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Texture "loadFromFile" does not work
« Reply #2 on: April 09, 2019, 06:20:55 pm »
Thank you very much!
That fixed it.

 

anything