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

Author Topic: sprite rendering problem  (Read 1473 times)

0 Members and 3 Guests are viewing this topic.

chehob

  • Newbie
  • *
  • Posts: 4
    • ICQ Messenger - 366770674
    • View Profile
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

chehob

  • Newbie
  • *
  • Posts: 4
    • ICQ Messenger - 366770674
    • View Profile
sprite rendering problem
« Reply #1 on: June 14, 2011, 03:00:08 pm »
Source image:
Wrong:
Correct:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sprite rendering problem
« Reply #2 on: June 14, 2011, 03:16:15 pm »
Is it really this code that produces this output??
Laurent Gomila - SFML developer

chehob

  • Newbie
  • *
  • Posts: 4
    • ICQ Messenger - 366770674
    • View Profile
sprite rendering problem
« Reply #3 on: June 14, 2011, 03:24:33 pm »
Quote from: "Laurent"
Is it really this code that produces this output??


Code that doesn't work normally:
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;
}


This one does:
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);

   sf::Shape Line = sf::Shape::Line(0, 0, 0, 0, 1, sf::Color(0,0,0,0));

   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.Draw(Line);

      App.Display();
   }

    return EXIT_SUCCESS;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sprite rendering problem
« Reply #4 on: June 14, 2011, 03:26:55 pm »
Weird... never seen this before :shock:

What's your OS? Graphics card? Are your graphics drivers up-to-date?
Laurent Gomila - SFML developer

chehob

  • Newbie
  • *
  • Posts: 4
    • ICQ Messenger - 366770674
    • View Profile
sprite rendering problem
« Reply #5 on: June 14, 2011, 03:30:50 pm »
Quote from: "Laurent"
Weird... never seen this before :shock:

What's your OS? Graphics card? Are your graphics drivers up-to-date?

Windows 7, Intel GMA 3100, don't know about drivers. I'm at workstation now, will try same at home.