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

Author Topic: sf::Texture::loadFromFile "Reason : Unable to open file"  (Read 11777 times)

0 Members and 1 Guest are viewing this topic.

BM

  • Newbie
  • *
  • Posts: 11
    • View Profile
sf::Texture::loadFromFile "Reason : Unable to open file"
« on: May 24, 2016, 10:20:56 pm »
I'm unable to load an image using loadFromFile. I keep getting the following message in the console : "Failed to load image "beach_ball". Reason: Unable to open file".

I made sure the working directory is what I think it is (project Properties -> Configuration Properties -> Debugging -> Working Directory) as well as tried with a full path instead like so : C:/C_FUN/SFML_1_1/SFML_1_1/beach_ball. I tried with different pictures and different type of file (png and jpg).

I double checked to make sure that I was using  the proper libraries :-d for debug, no sufix for release.

I'm using windows 7 with VS 2015 and SFML 2.3.2 for Visual C++ 14 (2015) - 64-bit and the project is set to x64.

I've looked around for quite some time before posting this and the main reason was either because the file was not in the right directory or the debug libraries were used for release or vice-versa.

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: sf::Texture::loadFromFile "Reason : Unable to open file"
« Reply #1 on: May 24, 2016, 10:28:45 pm »
Is it really called "beach_ball" and not "beach_ball.jpg" or "beach_ball.png"?

BM

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: sf::Texture::loadFromFile "Reason : Unable to open file"
« Reply #2 on: May 24, 2016, 10:31:19 pm »
Is it really called "beach_ball" and not "beach_ball.jpg" or "beach_ball.png"?
Yes, it's really called "beach_ball". But I did try renaming it with the extension and it still wouldn't work. I also tried with a different path.
« Last Edit: May 24, 2016, 10:33:08 pm by BM »

Erdrick

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
    • Email
Re: sf::Texture::loadFromFile "Reason : Unable to open file"
« Reply #3 on: May 25, 2016, 02:49:15 am »
Let me "bounce" an idea off you. (I'll show myself out... later)

Have you tried Windows Folder Options and confirm that "Hide extensions for known file types" is not checked?

Also if you could just copy and paste the exact Working Directory name you found in Visual Studio here for us to see?

I usually just select the <Browse...> option to see what directory it takes me to.

BM

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: sf::Texture::loadFromFile "Reason : Unable to open file"
« Reply #4 on: May 25, 2016, 08:54:31 pm »
Have you tried Windows Folder Options and confirm that "Hide extensions for known file types" is not checked?

That was the problem. Thanks a lot !

I knew it was going to be something silly...

Erdrick

  • Jr. Member
  • **
  • Posts: 61
    • View Profile
    • Email
Re: sf::Texture::loadFromFile "Reason : Unable to open file"
« Reply #5 on: May 26, 2016, 03:10:01 am »
Hey that's awesome, I'm glad my years of otherwise useless corporate existance surfaced something of value!

 

anything