Hello,
Here is the code:
#include <SFML/Graphics.hpp>
int main()
{
sf::VideoMode videoMode = sf::VideoMode(400, 300, 32);
sf::RenderWindow App(videoMode , "SFML Window");
App.SetFramerateLimit(60);
sf::Image Image;
if (!Image.LoadFromFile("xolo.png"))
{
return EXIT_FAILURE;
}
sf::Sprite Cross;
Cross.SetImage(Image);
while (App.IsOpened())
{
sf::Event Event;
while (App.PollEvent(Event))
{
// Window closed
if (Event.Type == sf::Event::Closed)
App.Close();
// [Esc] pressed
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
App.Clear();
App.Draw(Cross);
App.Display();
}
return EXIT_SUCCESS;
}
While running this program it doesnt draw the sprite, instead it draws a filled rectangle of sprite dimensions
BUT
when I add drawing the shape it actually works as supposed to be
sf::Sprite Cross;
Cross.SetImage(Image);
sf::Shape Line = sf::Shape::Line(0, 0, 0, 0, 1, sf::Color(0,0,0,0));
...
App.Clear();
App.Draw(Cross);
App.Draw(Line);
App.Display();
What's the problem here?
I'm using SFML 2.0