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

Author Topic: drawing Sprite from RenderTexture  (Read 2054 times)

0 Members and 1 Guest are viewing this topic.

sormo

  • Newbie
  • *
  • Posts: 6
    • View Profile
drawing Sprite from RenderTexture
« on: January 06, 2012, 07:18:09 pm »
I have strange behaviour while drawing sprite made from RenderTexture. I just create a RenderTexture with red background, draw a blue rectangle in the center and then I draw it on the RenderWindow.
Window is red, like a sprite is being drawn but blue rectangle is missing.
When I check the sprite saving it to a file, the blue rectangle is there.
I don't understand why is this happening that only red color of background is being drawn on the window.
btw I have onboard intel graphic card.
Code: [Select]

#include <SFML/Graphics.hpp>
 
int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");

sf::RenderTexture texture;
texture.Create(800,600);
texture.Clear(sf::Color::Red);

sf::RectangleShape shape(sf::Vector2f(50,50));
shape.SetFillColor(sf::Color::Blue);
shape.SetOrigin(25,25);
shape.SetPosition(400,300);

texture.Draw(shape);
texture.Display();

    while (window.IsOpened())
    {
        sf::Event event;
        while (window.PollEvent(event))
            if (event.Type == sf::Event::Closed)
                window.Close();
 
        window.Clear();
 
sf::Sprite s(texture.GetTexture());

//s.GetTexture()->CopyToImage().SaveToFile("file.png");

        window.Draw(s);
 
        window.Display();
    }
 
    return 0;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
drawing Sprite from RenderTexture
« Reply #1 on: January 06, 2012, 08:28:59 pm »
Quote
btw I have onboard intel graphic card.

That explains the problem.
Laurent Gomila - SFML developer

sormo

  • Newbie
  • *
  • Posts: 6
    • View Profile
drawing Sprite from RenderTexture
« Reply #2 on: January 06, 2012, 09:19:53 pm »
oh ... thx for the answer. I thought that there is a bug or I am doing somethong wrong

 

anything