SFML community forums

Help => General => Topic started by: Harald15 on April 09, 2019, 05:41:32 pm

Title: Texture "loadFromFile" does not work
Post by: Harald15 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)
Title: Re: Texture "loadFromFile" does not work
Post by: Laurent on April 09, 2019, 06:09:31 pm
Make sure that you're not using release SFML libraries in a debug build.
Title: Re: Texture "loadFromFile" does not work
Post by: Harald15 on April 09, 2019, 06:20:55 pm
Thank you very much!
That fixed it.