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

Author Topic: Failed to load image  (Read 5295 times)

0 Members and 1 Guest are viewing this topic.

zhinchliffe

  • Newbie
  • *
  • Posts: 18
    • View Profile
Failed to load image
« on: December 28, 2008, 08:58:54 pm »
For some reason, my images aren't loading - it just displays a white rectangle for all images.

Debug shows this:

Failed to load image "player.png". Reason : can't fopen
Failed to load image "bullet.png". Reason : can't fopen
Failed to load image "playertrail.png". Reason : can't fopen


I'm using the latest SVN revision of SFML with Xcode 2.4 on OS X 10.5. The images and .cpp files are in the same directory when built.

EDIT: On a friend's suggestion, I attempted to compile the sprite examples on the site. These do not work, either.

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Re: Failed to load image
« Reply #1 on: December 29, 2008, 12:19:49 am »
Quote from: "zhinchliffe"
The images and .cpp files are in the same directory when built.

You mean that the executable and the images are in the same directory, right?

Aval

  • Newbie
  • *
  • Posts: 34
    • View Profile
    • Email
Failed to load image
« Reply #2 on: December 29, 2008, 03:42:29 pm »
If you're debugging through vc++, you also need the images and dll's in the project directory.

dorkfish

  • Newbie
  • *
  • Posts: 38
    • View Profile
Failed to load image
« Reply #3 on: December 30, 2008, 12:35:58 am »
If you show us the relevant portion of your code, we might be able to come up with a solution.

Mr. Yes

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Failed to load image
« Reply #4 on: December 30, 2008, 01:24:55 am »
Quote from: "dorkfish"
If you show us the relevant portion of your code, we might be able to come up with a solution.

As he mentioned, he attempted to compile the source code on the site as well. So, you could in fact visit this page here to find the relevant portion of the code. Since this is apparently a problem with loading images, that relevant portion would be this:

Code: [Select]
// Load the sprite image from a file
sf::Image Image;
if (!Image.LoadFromFile("sprite.tga"))
    return EXIT_FAILURE;


(I'm the friend he mentioned in the first post, by the way)

chrz

  • Newbie
  • *
  • Posts: 8
    • View Profile
Failed to load image
« Reply #5 on: December 30, 2008, 02:07:19 am »
or try to load the image with the absolute path like Image.LoadFromFile("C:\myproject\sprite.png") then you can figure out, if the image-place is wrong

zhinchliffe

  • Newbie
  • *
  • Posts: 18
    • View Profile
Failed to load image
« Reply #6 on: December 31, 2008, 11:22:22 pm »
just tried with absolute path, still no dice.

dorkfish

  • Newbie
  • *
  • Posts: 38
    • View Profile
Failed to load image
« Reply #7 on: January 01, 2009, 02:45:41 am »
i remember having trouble with this on mac os, as well. Try creating an application bundle for the test app, and use cocoa's bundle-handling code to load your images from the bundle's resource directory. also, try putting the images in the directory above the one the executable's in.

zhinchliffe

  • Newbie
  • *
  • Posts: 18
    • View Profile
Failed to load image
« Reply #8 on: January 02, 2009, 02:00:12 am »
Quote from: "dorkfish"
use cocoa's bundle-handling code to load your images from the bundle's resource directory.
Alright, I'll need a bit more help than that, since I'm not a cocoa programmer. How exactly would I go about doing this?

 

anything