问题
I am using SFML 2.2 and Visual Studio Express 2013.
I simply want to load a texture and apply it to a sprite just like it is done in the tutorials at http://www.sfml-dev.org/tutorials/2.2/graphics-sprite.php.
The problem is that texture.loadFromFile() doesn't work at all for me. I have tried to place my file in a thousand different places and I always get the same result. Finally I decided to use the full path, same problem. I also tried different formats: PNG, GIF, JPG, BMP. I also tried to save them with different software: Photoshop, GIMP, paint. Nothing helps. The only error message displayed is:
Failed to load image "
Exactly like that, only one double quote at the end.
Help!
Here's the minimal code I tried.
#include <SFML/Graphics.hpp>
int main() {
sf::Texture texture;
if (!texture.loadFromFile("C:\\temp.png"))
return 1;
return 0;
}
回答1:
I figured out what the problem was.
I was running in debug mode but had configured the non-debug .lib files in the Linker under additional dependencies. Switching the configuration to Release suddenly made everything work.
To get the debug configuration to work, I just had to change the names from sfml-graphics.lib to sfml-graphics-d.lib (and so on). That did the trick!
Thanks everybody for the help!
来源:https://stackoverflow.com/questions/28289059/texture-loadfromfile-doesnt-work