SFML community forums

Help => Graphics => Topic started by: daHeartless on December 01, 2022, 08:31:53 pm

Title: Texture is not rendered
Post by: daHeartless on December 01, 2022, 08:31:53 pm
Hi,
I am trying to render a texture but I get only a black screen everytime I compile the code without any error. It compiles just fine with the examples from sfml website.
** I am on macOS, using CLion.
void Player::initializeTexture() {
/*
     * A texture will be loaded from a file.
     */



    if(!this->texture.loadFromFile("/Users/ismailsafwat/CLionProjects/ShapeShooters/Textures/sfmliconbig.png")){
        std::cout << "ERROR::PLAYER::INITIALIZETEXTURE::Failed to load the file!" << "\n";
    }
}
 
Title: Re: Texture is not rendered
Post by: Sean Mulligan on December 01, 2022, 09:44:54 pm
Hey, you forgot your "C:" at the beginning of the file path. You're on Windows right?

If you don't want a full file path look here:
https://en.sfml-dev.org/forums/index.php?topic=7701.0
Title: Re: Texture is not rendered
Post by: daHeartless on December 01, 2022, 10:06:11 pm
Sorry for not mentioning that, I edited the post now. No, I am on macOS.
Title: Re: Texture is not rendered
Post by: eXpl0it3r on December 02, 2022, 08:43:55 am
Does the file load successfully?
Title: Re: Texture is not rendered
Post by: daHeartless on December 02, 2022, 05:15:06 pm
yes, I assume it loads successfully because I do not get any error message.
Title: Re: Texture is not rendered
Post by: eXpl0it3r on December 02, 2022, 07:53:52 pm
How are you rendering the texture then?
Title: Re: Texture is not rendered
Post by: daHeartless on December 03, 2022, 06:55:39 pm
Just fixed it today, it was the order of the function implementation that caused it.