2
« on: November 26, 2010, 11:26:04 am »
Hello @ all,
i want to load an image in my render window, but it shows me only a white square with the size of my IntRect and the return is 5.
I use QT and the image is in the release directory.
i hope you can help me:)
#include <SFML/Graphics.hpp>
int main (){
sf::RenderWindow window(
sf::VideoMode (800, 600, 32), "Fenster", sf::Style::Close, sf::WindowSettings(32,0,0));
window.UseVerticalSync(true);
sf::Image image;
if (!image.LoadFromFile("man.GIF")) {
return 5;
}
sf::Sprite sprite;
sprite.SetImage(image);
sprite.SetPosition(sf::Vector2f(0, 0));
sprite.SetSubRect(sf::IntRect(0, 0, 38 ,44));
while (window.IsOpened()){
sf::Event event;
window.GetEvent(event);
switch(event.Type){
default:{
break;
}
case sf::Event::Closed:{
window.Close();
break;
}
case sf::Event::KeyPressed:{
switch (event.Key.Code){
default: break;
case sf::Key::Escape:
window.Close();
break;
}
}
}
window.Clear(sf::Color(200,200,200,255));
window.Draw(sprite);
window.Display();
}
return 0;
}