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

Author Topic: unable to open file , read details please.[Linux]  (Read 1604 times)

0 Members and 1 Guest are viewing this topic.

deepukps

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
unable to open file , read details please.[Linux]
« on: June 29, 2016, 12:12:42 pm »
This is my code for drawing a circle with a texture loaded from file .
#include<SFML/Graphics.hpp>
#include<SFML/Window.hpp>

int main()
{
        sf::ContextSettings settings ;
        settings.antialiasingLevel = 8 ;
        sf::RenderWindow window(sf::VideoMode(800,600) , "Shapes"  , sf::Style::Default , settings) ;
        sf::CircleShape circle ;
        circle.setRadius(80) ;
        circle.setPointCount(200) ;
        sf::Texture texture ;
        texture.loadFromFile("/home/deepukps/Downloads/texture.jpg") ;
        circle.setTexture(&texture) ;
       
        while (window.isOpen())
        {
                sf::Event event ;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close() ;
                }
                window.clear() ;
                window.draw(circle) ;
                window.display() ;
        }
       
        return 0 ;
}
 

And this is how I linked the linked the libraries after compiling my code -
g++ shape.o -o sfml-app -lsfml-graphics -lsfml-window -lsfml-system

This is the error message I get - Failed to load image "/home/deepukps/Downloads/texture.jpg". Reason: Unable to open file
What exactly am I doing wrong?
« Last Edit: June 29, 2016, 12:15:21 pm by deepukps »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10920
    • View Profile
    • development blog
    • Email
AW: unable to open file , read details please.[Linux]
« Reply #1 on: June 29, 2016, 01:09:05 pm »
Does the texture exist at the specific location? Does application have read access?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

deepukps

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: unable to open file , read details please.[Linux]
« Reply #2 on: July 01, 2016, 10:21:45 am »
Yes the texture exists at that specific location .  I don't know what read access means in this context .

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10920
    • View Profile
    • development blog
    • Email
Re: unable to open file , read details please.[Linux]
« Reply #3 on: July 01, 2016, 12:54:28 pm »
You're using Linux but you don't understand what file/read/write access is? Does the chmod command mean something to you? Make sure your application can open and read from the texture file, i.e. that the file has the right permission.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

deepukps

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: unable to open file , read details please.[Linux]
« Reply #4 on: July 01, 2016, 04:01:36 pm »
Fixed. I had to change .jpg to .JPG in my code. Thanks for the help eXpli0it3r.