SFML community forums

Help => Graphics => Topic started by: Navhkrin on February 07, 2016, 01:58:39 pm

Title: Texture does not load properly
Post by: Navhkrin on February 07, 2016, 01:58:39 pm
Code =
sf::Texture img;
      if (!img.loadFromFile("img.png")) {
         throw std::runtime_error("Could not load image.png");
      }

I copied that "img.png" to everywhere, from exe to project directory to directory where vcproject is located. It still fails to load.
This is working directory of project = $(ProjectDir)
Title: Texture does not load properly
Post by: eXpl0it3r on February 07, 2016, 04:27:51 pm
What does the console output say?
Title: Re: Texture does not load properly
Post by: Navhkrin on February 07, 2016, 05:00:44 pm
no output on console , not even std::cout << "test" works
Title: Texture does not load properly
Post by: eXpl0it3r on February 07, 2016, 07:28:35 pm
Windows?

Did you build it with subsystem set to console?
Title: Re: Texture does not load properly
Post by: Navhkrin on February 12, 2016, 02:14:47 pm
It was set to Windows subsystem, i chanced it to console, now im getting messages on console but still no image is being drawn.

This is the console output
Failed to load image "Press any key to continue . . .
Title: Re: Texture does not load properly
Post by: Mr_Blame on February 12, 2016, 03:50:36 pm
Check your image file name very carefully :)
Title: Texture does not load properly
Post by: eXpl0it3r on February 12, 2016, 04:26:26 pm
Is your PNG actually a PNG? And is it not an 8-bit PNG (not supported)?
Title: Re: Texture does not load properly
Post by: Hapax on February 12, 2016, 08:33:59 pm
Try using an absolute path to the file to check if the file can be loaded/is supported.
e.g. img.loadFromFile("C:/images/img.png")

If that works, your current working directory is not what you think it is.
If it does not, the image itself will need to be saved in a supported format.