Hello,
I'm trying to use off-screen drawing (in tutorial section "Drawing 2D stuff")
if i don't use set origin and scale it doesn't display properly.
What am I doing wrong?
sprite.setOrigin(0, 400);
sprite.scale(1, -1);
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(300, 400), "Render Texture");
sf::RenderTexture rt;
sf::Sprite sprite;
rt.create(300, 400);
//sprite.setOrigin(0, 400);
//sprite.scale(1, -1);
sf::RectangleShape rect;
rect.setPosition(10, 20);
rect.setSize(sf::Vector2f(50, 100));
rect.setFillColor(sf::Color(0, 255, 0));
rt.draw(rect);
sprite.setTexture(rt.getTexture());
sprite.setPosition(0, 0);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
window.clear(sf::Color::Black);
window.draw(sprite);
window.display();
}
return 0;
}