SFML community forums
Help => Graphics => Topic started by: paladin on November 24, 2008, 01:44:41 pm
-
Hi at all,
I'm new to SFML and trying to make a small Pong game with it.
There is only one problem:
I try to load an Image this way:
sf::Image image;
if(!image.LoadFromFile("test.png"))
return EXIT_FAILURE;
But LoadFromFile always returns false and the program exits with
Failed to load image "test.png". Reason: can't fopen
Now I tried
if(!image.LoadFromFile("/test.png"))
if(!image.LoadFromFile("./test.png"))
but this doesn't work, too.
The picture is definitely in the same folder as the exe.
Finally I tried this:
sf::Image image;
if(!image.LoadFromFile("C:/test/test.png"))
return EXIT_FAILURE;
So an absolute path works, but not a relative path.
The samples and the tutorials use relative paths and I could not find a solution to this problem in the forum and using google.
Now I would like to ask if this is a "bug" or a "feature" :wink:.
PS: Sorry for bad English, but I'm German and not very good in languages.
-
There's no bug, it's just that your working directory is not the one you think it is. How do you launch your executable ?
-
Are you using Visual Studio? If so, it tends not to set the paths correctly when debugging. Try setting the "working directory" in the project properties. If its not Visual Studio then sorry, I can't help, but I'm sure someone else can :)
-
I launch it using the Run button of CodeBlocks, but I will try starting the exe directly.
/e: Just tested and it works perfect :D :D Thank you for your help.