Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Outside Visual Studio screen goes black  (Read 3048 times)

0 Members and 1 Guest are viewing this topic.

crgimenes

  • Newbie
  • *
  • Posts: 12
    • View Profile
Outside Visual Studio screen goes black
« 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?

Tex Killer

  • Full Member
  • ***
  • Posts: 242
    • View Profile
Outside Visual Studio screen goes black
« Reply #1 on: November 01, 2011, 03:05:56 pm »
Could you give more details about wich textures causes the issue? Is it any specific one, or doesn't matter wich ones you remove?

crgimenes

  • Newbie
  • *
  • Posts: 12
    • View Profile
Outside Visual Studio screen goes black
« Reply #2 on: November 04, 2011, 10:19:39 am »
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.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Outside Visual Studio screen goes black
« Reply #3 on: November 04, 2011, 10:42:55 am »
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.
SFML 2.1

Naufr4g0

  • Full Member
  • ***
  • Posts: 112
    • View Profile
Outside Visual Studio screen goes black
« Reply #4 on: November 04, 2011, 12:50:27 pm »
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"

crgimenes

  • Newbie
  • *
  • Posts: 12
    • View Profile
Outside Visual Studio screen goes black
« Reply #5 on: November 04, 2011, 02:03:14 pm »
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.

Code: [Select]

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.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Outside Visual Studio screen goes black
« Reply #6 on: November 04, 2011, 03:48:14 pm »
OK, that sounds fine. Can you do a minimal app (use one of the demos) and see if that works?
SFML 2.1

crgimenes

  • Newbie
  • *
  • Posts: 12
    • View Profile
Outside Visual Studio screen goes black
« Reply #7 on: November 04, 2011, 04:40:02 pm »
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.

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Outside Visual Studio screen goes black
« Reply #8 on: November 04, 2011, 04:54:17 pm »
Grab yourself a copy of cppcheck, it will catch stuff like this :-)
SFML 2.1