SFML community forums

Help => General => Topic started by: reethok on March 07, 2016, 11:57:49 pm

Title: (Visual Studio 2015) Not loading resources (sf::Texture::loadFromFile)
Post by: reethok on March 07, 2016, 11:57:49 pm
Hello!,

It may be slightly off topic (as it's not entirely SFML related) but didn't knew where to ask. For some reason, when I launch my program from Visual Studio directly, it won't load the resources.

I have pasted the png files I use in my project in literally every folder inside the VS project directory, but it still doesn't work. I must add that it works correctly if i launch the exe from outside VS2015, but it's annoying having to do it every time.

Any ideas of why does this happen? Do I need to add all my resources to the IDE in the "resource Files" section?

Thanks in advance! :)
Title: Re: (Visual Studio 2015) Not loading resources (sf::Texture::loadFromFile)
Post by: Hapax on March 08, 2016, 02:50:12 am
When running a project from inside the IDE, the base path is the Working Directory whereas when you run from the executable, that base path is folder that the executable is in.

It 'should' work if it's inside the "project" directory. That is, the one with the vcxproj file (and likely your code files). This may be different, though, depending on the Working Directory setting in the project (Project Properties -> Configuration Properties -> Debugging -> Working Directory). You can change this to a specific folder if you like. If it's the project folder, it will be "$(ProjectDir)".

It might be worth actually testing to make sure that the resource works and loads okay before all of that, though. Simplest way to test it is to provide the full, absolute path and filename. If it works, the file's fine and you just need to set up the paths properly; if it fails, the file itself has problems and it may just be that the exact image format is unsupported (not all of each type will work).