SFML community forums

Help => Graphics => Topic started by: sormo on January 06, 2012, 07:18:09 pm

Title: drawing Sprite from RenderTexture
Post by: sormo 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;
}
Title: drawing Sprite from RenderTexture
Post by: Laurent on January 06, 2012, 08:28:59 pm
Quote
btw I have onboard intel graphic card.

That explains the problem.
Title: drawing Sprite from RenderTexture
Post by: sormo 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