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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - chehob

Pages: [1]
1
Graphics / sprite rendering problem
« on: June 14, 2011, 02:48:10 pm »
Hello,
Here is the code:

Code: [Select]

#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

Code: [Select]

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

Pages: [1]
anything