SFML community forums
Help => Graphics => Topic started 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)
-
What does the console output say?
-
no output on console , not even std::cout << "test" works
-
Windows?
Did you build it with subsystem set to console?
-
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 . . .
-
Check your image file name very carefully :)
-
Is your PNG actually a PNG? And is it not an 8-bit PNG (not supported)?
-
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.