SFML community forums
Help => Graphics => Topic started by: Ancient 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
-
Looks like your working directory is not the directory containing the exe.
-
Looks like your working directory is not the directory containing the exe.
of course it is
(http://i30.tinypic.com/2ldboeg.jpg)
#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;
}
-
"Brot.png"
Isn't it "bred.png" from your screenshot?
-
"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
-
das Brot = bread :wink:
-
das Brot = bread :wink:
ok everyone makes mistakes
but please help me to find the reason for the error
Ancient
-
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.
-
I'm just wondering why there isn't a ! in
if (Image.LoadFromFile("Brot.png"))
return EXIT_FAILURE;
... that would mean it returns fail even if it loads fine?
-
I'm just wondering why there isn't a ! in 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
#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:
||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
-
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