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

Author Topic: Visual C++ 2008 - How to add images  (Read 1794 times)

0 Members and 1 Guest are viewing this topic.

Rasenger

  • Newbie
  • *
  • Posts: 5
    • View Profile
Visual C++ 2008 - How to add images
« on: February 25, 2010, 10:31:44 am »
Hi! I've been using SFML for quite some time, but this is my first time using it with Visual Studio (Express). I got it working, no problem. But I really don't understand how resources, like images and sounds are managed in VC++. I can, of course, add images manually to Release or Debug folders, but that's not really a solution. I should be able to run the program from VC and from the Release folder without any tricks, so that the program can access my images and stuff.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Visual C++ 2008 - How to add images
« Reply #1 on: February 25, 2010, 10:38:50 am »
Right click on your project, select "Properties", then in the "Debugging" section change the "Working directory".
Laurent Gomila - SFML developer

Rasenger

  • Newbie
  • *
  • Posts: 5
    • View Profile
Visual C++ 2008 - How to add images
« Reply #2 on: February 25, 2010, 10:45:06 am »
I tried - got some error about missing dll. I really don't want to put any dlls into my image folder.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Visual C++ 2008 - How to add images
« Reply #3 on: February 25, 2010, 11:13:26 am »
You must know what happens when your executable needs to load an external file:
- DLLs must be either in the working directory, or in a directory that is in the PATH environment variable
- other files (referenced in your source code) must be relative to your working directory

So what is typically done is to have the executable + DLLs at the root of the application tree (that you define as the working directory), and then put resources such as images, sounds, etc. in a subfolder. For example, if you put your images in <root>/resources/images, and <root> is your working directory, then you must reference them as "resources/images/xxx.png" in your code.
Laurent Gomila - SFML developer

Rasenger

  • Newbie
  • *
  • Posts: 5
    • View Profile
Visual C++ 2008 - How to add images
« Reply #4 on: February 25, 2010, 11:22:22 am »
EDIT: It works. Thanks for help. The dll error was caused by me turning off manifest generation. What's that?

 

anything