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

Author Topic: Texture is not rendered  (Read 1813 times)

0 Members and 2 Guests are viewing this topic.

daHeartless

  • Newbie
  • *
  • Posts: 4
    • View Profile
Texture is not rendered
« 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";
    }
}
 
« Last Edit: December 01, 2022, 10:05:32 pm by daHeartless »

Sean Mulligan

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Texture is not rendered
« Reply #1 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

daHeartless

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Texture is not rendered
« Reply #2 on: December 01, 2022, 10:06:11 pm »
Sorry for not mentioning that, I edited the post now. No, I am on macOS.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Texture is not rendered
« Reply #3 on: December 02, 2022, 08:43:55 am »
Does the file load successfully?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

daHeartless

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Texture is not rendered
« Reply #4 on: December 02, 2022, 05:15:06 pm »
yes, I assume it loads successfully because I do not get any error message.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Texture is not rendered
« Reply #5 on: December 02, 2022, 07:53:52 pm »
How are you rendering the texture then?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

daHeartless

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Texture is not rendered
« Reply #6 on: December 03, 2022, 06:55:39 pm »
Just fixed it today, it was the order of the function implementation that caused it.