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.
#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;
}