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

Author Topic: New prob with sprite loading  (Read 4419 times)

0 Members and 1 Guest are viewing this topic.

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
New prob with sprite loading
« on: August 20, 2009, 04:07:41 pm »
hi again.

my problem is, that i wanted to open and load a sprite.
but now, he gives me an error-message:

Failed to load image "bred.png". Reason : Unable to open file.

the sprite is there were the *.exe is.
and another error ewhile i was trying to get some text:

Failed to load font "Times.ttf" <cannot open ressource>

pls help

Ancient

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New prob with sprite loading
« Reply #1 on: August 20, 2009, 04:44:48 pm »
Looks like your working directory is not the directory containing the exe.
Laurent Gomila - SFML developer

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
New prob with sprite loading
« Reply #2 on: August 20, 2009, 05:35:07 pm »
Quote from: "Laurent"
Looks like your working directory is not the directory containing the exe.


of course it is



Code: [Select]

#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Ancients Program");

    sf::Image Image;
    if (Image.LoadFromFile("Brot.png"))
    return EXIT_FAILURE;
    sf::Sprite Sprite(Image);

    sf::Font Arial;
    if (!Arial.LoadFromFile("Times.ttf"))
        return EXIT_FAILURE;
        sf::String Text("Ancient was here", Arial, 50);

    while (App.IsOpened())
    {

        sf::Event Event;
        while (App.GetEvent(Event))
        {
            if(!Image.LoadFromFile("Brot.JPG"))
            {
            }
            if (Event.Key.Code == sf::Key::Escape)
                {
                    App.Close();
                }
            if (Event.Type == sf::Event::Closed)
                    App.Close();

        }

        App.Clear(sf::Color(200, 0 , 0, 100));

        App.Draw(Sprite);

        App.Draw(Text);

        App.Display();
    }

    return EXIT_SUCCESS;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
New prob with sprite loading
« Reply #3 on: August 20, 2009, 05:43:41 pm »
Quote
Code: [Select]
"Brot.png"

Isn't it "bred.png" from your screenshot?
Laurent Gomila - SFML developer

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
New prob with sprite loading
« Reply #4 on: August 21, 2009, 02:51:47 pm »
Quote from: "Laurent"
Quote
Code: [Select]
"Brot.png"

Isn't it "bred.png" from your screenshot?


yes
i changed it becuase i thought u would
understand it much better in english than in german  :lol:
but it's the same.Also, if i change it,
the problem stays...

and u see, the font wont work either


Ancient

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
New prob with sprite loading
« Reply #5 on: August 21, 2009, 03:45:27 pm »
das Brot = bread  :wink:
SFML / OS X developer

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
New prob with sprite loading
« Reply #6 on: August 21, 2009, 03:52:27 pm »
Quote from: "Hiura"
das Brot = bread  :wink:


ok everyone makes mistakes
but please help me to find the reason for the error





Ancient

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
New prob with sprite loading
« Reply #7 on: August 21, 2009, 05:08:55 pm »
maybe you don't have rights to open the files
or you're not in the good working directory.

If you use the input arguments of function main to check which is the current working directory.
SFML / OS X developer

eleinvisible

  • Newbie
  • *
  • Posts: 47
    • View Profile
New prob with sprite loading
« Reply #8 on: August 21, 2009, 11:20:36 pm »
I'm just wondering why there isn't a ! in
Code: [Select]
if (Image.LoadFromFile("Brot.png"))
    return EXIT_FAILURE;
... that would mean it returns fail even if it loads fine?

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
New prob with sprite loading
« Reply #9 on: August 22, 2009, 01:21:33 pm »
Quote from: "eleinvisible"
I'm just wondering why there isn't a ! in
Code: [Select]
if (Image.LoadFromFile("Brot.png"))
    return EXIT_FAILURE;
... that would mean it returns fail even if it loads fine?


i tryed some ideas but nothing work
here is antoher code->same mistakes

i took it from the thread above so,
dont wonder :D
Code: [Select]

#include <SFML/Graphics.hpp>

using namespace sf;

int main(int argc, char *argv[])
{
    RenderWindow App(VideoMode(800,600,32), "Test", Style::Titlebar);
    App.Clear(Color(255,255,255));

    Image i_one;
    if( !i_one.LoadFromFile("rabe.jpg") )
        return EXIT_FAILURE;
    Sprite s_one(i_one);

    Image i_two;
    if( !i_two.LoadFromFile("rabe.jpg") )
        return EXIT_FAILURE;
    Sprite s_two(i_two);

    App.Draw(s_one);
    App.Draw(s_two);
    App.Display();
    Sleep(1.0f);
    App.Close();

    return EXIT_SUCCESS;
}


while im compiling i get warnings like that:
Code: [Select]

||Info: resolving vtable for sf::Spriteby linking to __imp___ZTVN2sf6SpriteE |
||warning: auto-importing has been activated without --enable-auto-import specified on the command line.|
||=== Build finished: 0 errors, 1 warnings ===|

does someone know what that means?



Ancient

Ancient

  • Newbie
  • *
  • Posts: 11
    • View Profile
New prob with sprite loading
« Reply #10 on: August 22, 2009, 02:37:12 pm »
I got it!

thanks to you Hiura : You were right.
I put it into the wrong directory so that he couldnt find
it.
thanks guys....






best wishes Ancient

 

anything