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

Author Topic: Project wont render launching from VS  (Read 2178 times)

0 Members and 1 Guest are viewing this topic.

Aaron1Olson

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Project wont render launching from VS
« on: February 13, 2017, 10:48:33 pm »
I'm having a problem with my project. (or annoyance , really)

I can compile just fine, but when I launch the application under Release or Debug in Visual Studio 2015, nothing gets rendered within the window, only the color of .clear(). If I go into the Release or Debug directory of my project and launch the executable, all the SFML Text shows up fine.

Is this a problem with Visual Studio settings I'm not aware of?

Sorry in advance if this has been answered elsewhere, I've tried to search around as much as possible but I cant really word the problem well. Thank you  :)
« Last Edit: February 13, 2017, 11:08:58 pm by Aaron1Olson »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11029
    • View Profile
    • development blog
    • Email
Re: Project wont render launching from VS
« Reply #1 on: February 14, 2017, 01:03:06 am »
Your font/resources are probably not loading. The fact that you don't notices this, shows that you're not checking whether loading was successful or not. ;)

Place the resources in the working directory or adjust the working directory to point where the resources are located and make sure to check the loading.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Project wont render launching from VS
« Reply #2 on: February 14, 2017, 01:03:38 am »
Sharing some complete and minimal code that reproduces this problem would help a lot otherwise it's just guessing.

Here's my guess:
Are you loading the font without checking the result of "loadFromFile()"?
Chances are that the working directory when run from inside VS is different to the one when run from the executable (the folder of the executable). Therefore, the font needs to be available in the Current Working Directory as well as the Debug and Release folders.
Testing loadFromFile would let you know if this is the case (e.g. "failed to load font").

Just so you know, the default CWD is the same folder as the source files.
To change it, go to your project's properties and "Working Directory" is under "Debugging".

EDIT: @eXpl0it3r, snap! ;D
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11029
    • View Profile
    • development blog
    • Email
Re: Project wont render launching from VS
« Reply #3 on: February 14, 2017, 01:05:58 am »
Haha, I had this thread open for a while and only now quickly wrote something down. Now it feels like I was waiting for you to answer, so I could ninja you. ;D
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Aaron1Olson

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Project wont render launching from VS
« Reply #4 on: February 14, 2017, 02:42:38 am »
Didn't even think of that  :o

Thank you both for the help. I'll add the check to make sure the font is loading. Didn't realize the working directories are different either but that would have been a dead giveaway if I had done the check.
I'm still learning some of the basics of C++,  practicing inheritance and pointers and etc so maybe SFML is a bit out of my scope for now but it's definitely fun to use.  :)

 

anything