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

Author Topic: Unable to load images  (Read 3665 times)

0 Members and 1 Guest are viewing this topic.

HannesP

  • Newbie
  • *
  • Posts: 6
    • View Profile
Unable to load images
« on: May 20, 2009, 01:02:04 pm »
When I try to load an image using LoadFromFile(), I get the following error message:

Failed to load image "protagonist.png". Reason : can't fopen

The image is located in the same directory as the binary (something I eventually want to avoid). I've also tried relative paths without success.

I'm developing using Xcode, and my SFML version is 1.4. I've tried other image formats as well (though this is unlikely the problem, since it complains about that it can't even open the file).

Any ideas? All help is appreciated!

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Unable to load images
« Reply #1 on: May 20, 2009, 02:20:10 pm »
Try to load the image using an absolute path to make sure it isn't path-related.

HannesP

  • Newbie
  • *
  • Posts: 6
    • View Profile
Unable to load images
« Reply #2 on: May 20, 2009, 02:31:31 pm »
Quote from: "Tank"
Try to load the image using an absolute path to make sure it isn't path-related.


Ah, of course, should've tried that earlier... anyway, it works. Thanks :)

So the problem is that the base path isn't the location of the binary. Could this be changed? I don't want to ship a game that uses absolute paths...

Daazku

  • Hero Member
  • *****
  • Posts: 896
    • View Profile
Unable to load images
« Reply #3 on: May 20, 2009, 02:42:09 pm »
In your project properties you should be able to change that.
Pensez à mettre le tag [Résolu] une fois la réponse à votre question trouvée.
Remember to add the tag [Solved] when you got an answer to your question.

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Unable to load images
« Reply #4 on: May 21, 2009, 12:03:57 pm »
When this is your director structure:
Code: [Select]
MyProject\Debug\Blah.exe
MyProject\Release\Blah.exe
MyProject\


...then your resources must take place in MyProject\. I hope that's correct, haven't used MSVC for a (long) while.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Unable to load images
« Reply #5 on: May 21, 2009, 02:36:49 pm »
Quote from: "HannesP"
So the problem is that the base path isn't the location of the binary. Could this be changed? I don't want to ship a game that uses absolute paths...


All of the paths on the Mac are relative to the actual executable within the .app bundle.

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Unable to load images
« Reply #6 on: May 21, 2009, 03:32:15 pm »
Quote from: "Tank"
When this is your director structure:
Code: [Select]
MyProject\Debug\Blah.exe
MyProject\Release\Blah.exe
MyProject\


...then your resources must take place in MyProject\. I hope that's correct, haven't used MSVC for a (long) while.

That's correct.