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

Author Topic: Textures not loading, and I tried EVERYTHING  (Read 2059 times)

0 Members and 1 Guest are viewing this topic.

Rozdarty

  • Newbie
  • *
  • Posts: 2
    • View Profile
Textures not loading, and I tried EVERYTHING
« on: December 08, 2020, 01:04:16 am »
Yes, I included the file type (png), yes I tried making a sprite, yes I have it in the same folder as the "Source.cpp" file. I am getting so frustrated as I have wasted the past hour or so trying to figure out why it is doing this. I am thinking it might be the way I linked the project? The thing is, though, every other type of code works with these project settings, EXCEPT adding textures.
Any ideas?
Thanks.

#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 800), "Good");
        sf::Texture texture;
        texture.loadFromFile("sfml logo.png");
        sf::Sprite sprite;
        sprite.setTexture(texture);
        sprite.setColor(sf::Color::Red);

        while (window.isOpen())
        {
                sf::Event ev;
                while (window.pollEvent(ev))
                {
                        if (ev.type == sf::Event::Closed)
                        {
                                window.close();
                        }
                }
                window.clear();
                window.draw(sprite);
                window.display();
        }
}
 

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Textures not loading, and I tried EVERYTHING
« Reply #1 on: December 08, 2020, 02:35:22 am »
Any error message? Something in the console? Have you tried checking the return value of loadFromFile?
WTF happens when you run your code... we don't know

Rozdarty

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Textures not loading, and I tried EVERYTHING
« Reply #2 on: December 08, 2020, 03:08:32 am »
I get the usual unhandled exception error with the random symbols in the console, the usual error you get when the compiler can't recognize the texture file.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Textures not loading, and I tried EVERYTHING
« Reply #3 on: December 08, 2020, 04:49:47 am »
Random symbols in the console usually happens when you're mixing debug and release. (when you're using the release version of SFML but compiling in debug mode, or debug version and compiling in release mode)

 

anything