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

Author Topic: weird error with texture loading  (Read 3921 times)

0 Members and 1 Guest are viewing this topic.

Phictus

  • Newbie
  • *
  • Posts: 1
    • View Profile
weird error with texture loading
« on: June 21, 2021, 01:12:31 pm »
this is the code:
sf::Texture texture;
if (!texture.loadFromFile("assets/textures/spaceship.png"))
    __debugbreak();
m_Sprite.setTexture(texture);
 
but i get this error in the console: "Failed to load image "". Reason: Unable to open file"
it doesn't even say the texture path that it tried to open so i don't think that the image is the problem.
« Last Edit: June 21, 2021, 01:17:46 pm by Phictus »

Stauricus

  • Sr. Member
  • ****
  • Posts: 369
    • View Profile
    • A Mafia Graphic Novel
    • Email
Re: weird error with texture loading
« Reply #1 on: June 21, 2021, 01:19:33 pm »
on the other hand, i think the image is exactly the problem  ;D
make sure it is not corrupted (can you open it with an image viewer, for example?)
and how is your project folder (specifically, the png folder)? personally i like screenshots to help finding the problem.
if you're using Linux, you can try adding " ./ " at the image path, altough i don't think this is going to solve the problem.
"./assets/textures/spaceship.png"
Visit my game site (and hopefully help funding it? )
Website | IndieDB

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
Re: weird error with texture loading
« Reply #2 on: June 21, 2021, 03:40:51 pm »
Or you might be linking release libraries in debug mode.
Make sure you use debug libraries in debug mode and release libraries in release mode.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/