SFML community forums
Help => Graphics => Topic started by: drakelord on May 30, 2009, 08:16:23 am
-
Mkay, so, interesting problem here.
sf::Image LoadScreenImage;
std::string test = "res\\title.png";
if(!LoadScreenImage.LoadFromFile(test));
FAILED_TO_GET_RESOURCE
Results in the program not being able to load the image and going down.
sf::Image LoadScreenImage;
if(!LoadScreenImage.LoadFromFile("res\\title.png"));
FAILED_TO_GET_RESOURCE
On the other hand, works fine. It says right in the documentation that it wants a std::string, but when I pass it one versus manually typing it in, it doesn't work.
How to fix?
-
Well, this code is so straight-forward that I can't believe it makes a difference at runtime. It is exactly the same.
Can you show a complete and minimal example that reproduces the problem? It's it's that simple, the minimal code should be very short.
-
So, oddly enough, while getting ready to make and post a test page, I noticed the problem right in the code I posted.
if(!LoadScreenImage.LoadFromFile(test));
That semicolon at the end somehow caused it to fail. Noo idea how, but it did. *Fails*
Thanks for the help though, =D
-
the semicolon is the Line Terminator (Saying the statements over and to execute the next line), therefore your statement will always return a resource error.
-
the semicolon is the Line Terminator (Saying the statements over and to execute the next line), therefore your statement will always return a resource error.
But when I put the string in manually, even with the semi-colon, it still worked. That was why I was confused. The semi-colon should kill it both ways.