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

Author Topic: loadFromFile doesn't work but shows no error message  (Read 3958 times)

0 Members and 1 Guest are viewing this topic.

MesMeRriZze

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
loadFromFile doesn't work but shows no error message
« on: March 10, 2016, 06:32:06 am »
I was trying to loadfromfile for my texture object, however, it doesn't work and prints out nothing in the console window. Even if I download someone else's project from github, it's still not working and having the same issue.

I have tried putting my image in all the possible directory that the visual studio 2013 may read.

So I'm wandering that is there something about the project properties that I should change in visual studio 2013? I've almost tried all possibilities..... but it's still not working.... and there's not even a similar problem in the forum, since they all, at least, get an error message. Thanks

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: loadFromFile doesn't work but shows no error message
« Reply #1 on: March 10, 2016, 09:49:08 am »
"It's not working" is not a problem description. What do you mean with "not working"?
Provide a minimal and compilable example.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

MesMeRriZze

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: loadFromFile doesn't work but shows no error message
« Reply #2 on: March 11, 2016, 12:48:33 am »
      if (!illustration->loadFromFile(path)){
         cout << "ERROR" << endl;
      }

Like that, I'm sure that the path was correct. However, I'm trying to use sfml for 32 bit now, and it seems to be working. So I wonder is it possible that the 64 bit sfml usage is different than that of 32 bit in loadFromFile?

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: loadFromFile doesn't work but shows no error message
« Reply #3 on: March 11, 2016, 08:46:51 am »
Did you download the 64-bit binaries? Did you change the configutation of you project from x86 to x64?

MesMeRriZze

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: loadFromFile doesn't work but shows no error message
« Reply #4 on: March 11, 2016, 03:22:29 pm »
Yes, I was using the 64 bit version with my project settings all set to x64, but it was not working for almost an entire week LOL.... The 32 bit is working pretty fine now. Is there something else I need to do to use the 64 bit version of it? like additional linker configurations?

tank69

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: loadFromFile doesn't work but shows no error message
« Reply #5 on: April 05, 2016, 09:45:28 pm »
Hi, i am facing the same issue right now except that im sure that i am using the right versions of sfml, i am using codeblocks.

The problem i have is that .loadFromFile is indeed working, if i intentionally type an incorrect image name, just to test if it returns an error, well it does so im sure it can find the file i was specifying. but i am wondering why does it not drawn on the window.

here is my code.what am i missing???

 


sf::Texture ptexture;
               if(!ptexture.loadFromFile("tank.png"))
                return 1;
            ptexture.setSmooth(true);
           
sf::Sprite psprite;
            psprite.setTexture(ptexture);
            psprite.setPosition(200,200);

while (window.isOpen())
{
window.draw(sprite);
}
 

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: loadFromFile doesn't work but shows no error message
« Reply #6 on: April 05, 2016, 10:26:14 pm »
here is my code.what am i missing???

You are not clearing or displaying the window. You also aren't handling window events.

http://www.sfml-dev.org/tutorials/2.3/graphics-draw.php

tank69

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: loadFromFile doesn't work but shows no error message
« Reply #7 on: April 06, 2016, 12:35:59 am »
i have those on my code, i just minimize the code that i need to show. and also the window.draw(sprite) should be window.draw(psprite) typo on the post.

tank69

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: loadFromFile doesn't work but shows no error message
« Reply #8 on: April 06, 2016, 12:37:56 am »
and if i cleared the window, then absolutely there would be nothing displayed...

doingit

  • Newbie
  • *
  • Posts: 17
    • View Profile
Re: loadFromFile doesn't work but shows no error message
« Reply #9 on: April 06, 2016, 12:52:20 am »
With so few information, not many people will be able to help.

What is the behavior you are getting, what is the expected?

My assumption is that you're indeed clearing the screen and displaying the window. If so, it should draw, if not try changing the clear color and see if the clear method is even working, as well.

What is actually working? is it just sprites not showing? is the clear color operating correctly? Is anything else other than the sprite malfunctioning? Is the texture rect on default max size; have you altered it?

More detail will help folks help you easier.

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: loadFromFile doesn't work but shows no error message
« Reply #10 on: April 06, 2016, 04:26:24 pm »
@tank69 Your posts are a little confusing. You said you have everything I pointed out in your code, but then your next post makes it seems like you actually aren't clearing the window. It also seems like you're misunderstanding the purpose of clearing the window. Basically, as the tutorial I linked points out, you should be doing something like this in your loop

while (window.isOpen())
{
   // Window event handling here

   window.clear();
   window.draw(psprite);
   window.display();
}
 

If you do indeed have all of that already in your code, then you should include that in your post. Those things are necessary for a minimally working example. Otherwise you will lead people that are trying to help you down the wrong path on what might be going wrong.