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

Author Topic: weird error with texture loading  (Read 1613 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: 299
    • View Profile
    • 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"

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 9909
    • 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
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

 

anything