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

Author Topic: Failed to load image.  (Read 4603 times)

0 Members and 1 Guest are viewing this topic.

Chiggy_Playz

  • Newbie
  • *
  • Posts: 15
    • View Profile
Failed to load image.
« on: April 15, 2019, 01:28:23 pm »
so i am very new to SFML (less then 24 hrs) and i have encountered with a weird problem. I am trying to load a texture and when i run my code, the cmd shows "failed to load ... " in the very beginning and then prints all sort of weird random gibberish stuff. I am using visual studio 2017 and SFML 2.5 . Also i found my working dir by using system(dir) and placed my png there but still doesnt work. also if i remove the "if condition" everything is fine. Here is my code :
#include <SFML/Graphics.hpp>
#include "iostream";
 using namespace std;
 using namespace sf;
 int main()
 {
    RenderWindow window(VideoMode(1000, 1000), "Chiggy's Tic Tac Toe!");
    CircleShape shape(100.f);
    shape.setFillColor(Color::Blue);
    Texture texture;
    if (!texture.loadFromFile("D:\Developement\VisualStudio\sfml\try\Project0\Project0\mad.png")) {  
         
           cout<<"Mario failed to load horribly"<<endl; system("pause"); //return EXIT_FAILURE; }

     while (window.isOpen()) {

           Event event;
           
            while (window.pollEvent(event)) {
                 if (event.type == Event::Closed)
                 window.close();
}

 window.clear(Color::Black);
 window.draw(shape);
 window.display();
}
return 0; }
« Last Edit: April 15, 2019, 01:54:13 pm by Laurent »

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: Failed to load image.
« Reply #1 on: April 15, 2019, 01:40:18 pm »
Most likely you're linking the debug SFML in release mode, or the release SFML in debug mode.
« Last Edit: April 15, 2019, 01:54:20 pm by Laurent »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Failed to load image.
« Reply #2 on: April 15, 2019, 01:56:59 pm »
Also, use \\ or / in string literals. The single back-slash is used for escape sequences.
Laurent Gomila - SFML developer

Chiggy_Playz

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Failed to load image.
« Reply #3 on: April 15, 2019, 02:12:32 pm »
Also, use \\ or / in string literals. The single back-slash is used for escape sequences.

didnt work i did try it. still shows the things i have linked in the attachment. also the white thing that you see on the right side is the windows which is supposed to be black.


Chiggy_Playz

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Failed to load image.
« Reply #4 on: April 15, 2019, 02:13:52 pm »
Most likely you're linking the debug SFML in release mode, or the release SFML in debug mode.

What do you mean? how do i solve this? Also i have attached a picture so as to explain what i get.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Failed to load image.
« Reply #5 on: April 15, 2019, 02:24:50 pm »
Don't link to sfml-xxx.lib (release libraries) when you build in Debug mode. It should be sfml-xxx-d.lib (debug libraries).

« Last Edit: April 15, 2019, 02:26:24 pm by Laurent »
Laurent Gomila - SFML developer

Chiggy_Playz

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Failed to load image.
« Reply #6 on: April 15, 2019, 02:29:00 pm »
Don't link to sfml-xxx.lib (release libraries) when you build in Debug mode. It should be sfml-xxx-d.lib (debug libraries).




Actuall i am the biggest noob in this universe and dont know the difference. all i know i did is I followed how to install on wikihow. Here is the link

https://www.wikihow.com/Set-Up-SFML-in-a-Project-on-Visual-Studio-2017

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Failed to load image.
« Reply #7 on: April 15, 2019, 02:36:32 pm »
If you're "the biggest noob in this universe", then let me give you a very important advice: always start with the official tutorials, not some random stuff on a general how-to website.

We've spent a lot of time writing detailed tutorials, with screen captures, that address the most common mistakes -- you see, this one is even in a red box. So please read our tutorials before asking anything.
Laurent Gomila - SFML developer

Chiggy_Playz

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Failed to load image.
« Reply #8 on: April 15, 2019, 07:19:30 pm »
Don't link to sfml-xxx.lib (release libraries) when you build in Debug mode. It should be sfml-xxx-d.lib (debug libraries).



this worked. firstly i checked the libraries, I found that i had installed sfml-graphics along with sfml-graphics-d

then i changed my config from build to release and voila it worked. thanx a lot man. appreciate it.

 

anything