SFML community forums
Help => Graphics => Topic started by: crgimenes on November 01, 2011, 02:59:55 pm
-
Hello everyone.
My game runs inside Visual Studio without problems. But when I try to run the same binary outside Visual Studio, textures do not appear and the screen goes black. The textures are loaded and the path is correct but do not appear on the screen.
So I tried to remove some textures and everything work ok, inside and outside of Visual Studio, them I put the textures back again and the problem appears.
I did all the tests in release mode.
am I running into some limit or have a configuration that I should adjust?
-
Could you give more details about wich textures causes the issue? Is it any specific one, or doesn't matter wich ones you remove?
-
Any image that I remove everything works. But what intrigues me is that the same binary (compiled in release mode) works correctly in the visual stidio and does not work out of it.
-
When you say you are running it outside VS, how do you mean? Are you just running the exe from the Debug or Release directory? If so your paths will be incorrect.
Copy everything to a new folder, exe, resource tree, SFML DLLs (if not static) and libpng, etc, and try that.
If that doesn't work, let us know what VS you have and more about your system.
-
The path for the texture is absolute or relative?
Usually I use a relative path for textures, so when I copy the binary file with the image files in another folder I have no path issues.
I.E. "/graphics/player.png"
-
when I say "outside of Visual Studio" I mean:
I compile the executable, so I copy the exe file from release folder to the correct folder and finally I run the program, the images are loaded correctly, I can see it because otherwise the program would not load.
sf::Image player;
if (!player.LoadFromFile("textures\\player.png"))
{
std::cout << "erro textures\\player.png" << std::endl;
exit(1);
}
The path is dynamic but I am absolutely sure that the images are being loaded.
-
OK, that sounds fine. Can you do a minimal app (use one of the demos) and see if that works?
-
I solved the problem.
In my game engine is a boolean variable that tells whether the object will be drawn or not.
And I forgot to initialize this variable in the constructor of my class.
It is the most basic of all the commandments, initialize all variables.
-
Grab yourself a copy of cppcheck, it will catch stuff like this :-)