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

Author Topic: Problem with .loadFromFile()  (Read 1976 times)

0 Members and 1 Guest are viewing this topic.

Alidro

  • Newbie
  • *
  • Posts: 18
    • View Profile
Problem with .loadFromFile()
« on: March 08, 2017, 05:00:40 pm »
Hey there,

i am new to SFML and also to C++ kind of so dont expect me to know anything ;).
I did not quite understand how exactly the .loadFromFile() works with folders, I tried for example:
Font Arial;
Arial.loadFromFile("arial.ttf");
 
It worked as i had Arial.ttf in the same folder as the .exe and also in subfolders when i use Visual Studio to start the Program. But when I start the .exe manually, it could not load the files when in subfolders.

Sorry for any mistakes, I am German, so also feel free to write in german if wanted to and possible.




 

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Problem with .loadFromFile()
« Reply #1 on: March 08, 2017, 05:10:17 pm »
Files are loaded relative to the working directory. Visual Studio sets the working directory to where the project file is located by default. But if you start it through explorer the working directory is where you're starting the exe from.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Alidro

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Problem with .loadFromFile()
« Reply #2 on: March 08, 2017, 05:11:53 pm »
thanks for the fast reply,

so i cant put fonts and textures into folders?

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: Problem with .loadFromFile()
« Reply #3 on: March 08, 2017, 05:18:33 pm »
You can put resources in sub-directories. You just need to adjust your code accordingly.

Font Arial;
Arial.loadFromFile("MyFolder/arial.ttf");
 

Alidro

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Problem with .loadFromFile()
« Reply #4 on: March 08, 2017, 05:24:54 pm »
Ok Thanks