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

Author Topic: (Visual Studio 2015) Not loading resources (sf::Texture::loadFromFile)  (Read 2954 times)

0 Members and 1 Guest are viewing this topic.

reethok

  • Newbie
  • *
  • Posts: 23
    • View Profile
    • Email
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! :)

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
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).
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*