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

Author Topic: Texture does not load properly  (Read 1984 times)

0 Members and 1 Guest are viewing this topic.

Navhkrin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Texture does not load properly
« on: February 07, 2016, 01:58:39 pm »
Code =
sf::Texture img;
      if (!img.loadFromFile("img.png")) {
         throw std::runtime_error("Could not load image.png");
      }

I copied that "img.png" to everywhere, from exe to project directory to directory where vcproject is located. It still fails to load.
This is working directory of project = $(ProjectDir)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Texture does not load properly
« Reply #1 on: February 07, 2016, 04:27:51 pm »
What does the console output say?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Navhkrin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Texture does not load properly
« Reply #2 on: February 07, 2016, 05:00:44 pm »
no output on console , not even std::cout << "test" works

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Texture does not load properly
« Reply #3 on: February 07, 2016, 07:28:35 pm »
Windows?

Did you build it with subsystem set to console?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Navhkrin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Texture does not load properly
« Reply #4 on: February 12, 2016, 02:14:47 pm »
It was set to Windows subsystem, i chanced it to console, now im getting messages on console but still no image is being drawn.

This is the console output
Failed to load image "Press any key to continue . . .

Mr_Blame

  • Full Member
  • ***
  • Posts: 192
    • View Profile
    • Email
Re: Texture does not load properly
« Reply #5 on: February 12, 2016, 03:50:36 pm »
Check your image file name very carefully :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Texture does not load properly
« Reply #6 on: February 12, 2016, 04:26:26 pm »
Is your PNG actually a PNG? And is it not an 8-bit PNG (not supported)?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3346
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Texture does not load properly
« Reply #7 on: February 12, 2016, 08:33:59 pm »
Try using an absolute path to the file to check if the file can be loaded/is supported.
e.g. img.loadFromFile("C:/images/img.png")

If that works, your current working directory is not what you think it is.
If it does not, the image itself will need to be saved in a supported format.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*