Welcome, Guest. Please login or register.

Author Topic: RenderTexture texture flipped after copying  (Read 313 times)

0 Members and 1 Guest are viewing this topic.

texus

  • Sr. Member
  • ****
  • Posts: 466
    • View Profile
    • TGUI
    • Email
RenderTexture texture flipped after copying
« on: November 13, 2017, 07:26:56 pm »
Since commit 6b71456, copying a texture from a render texture causes it to be flipped.

Code to reproduce:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(400, 200), "SFML Window");

    sf::RectangleShape shape{{100, 100}};
    shape.setFillColor(sf::Color::Red);

    sf::RenderTexture rt;
    rt.create(200, 200);
    rt.clear(sf::Color::White);
    rt.draw(shape);
    rt.display();

    sf::Sprite s1(rt.getTexture());

    sf::Texture t = rt.getTexture(); // Copy texture before passing it to sprite
    sf::Sprite s2(t);
    s2.setPosition({200, 0});

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(s1);
        window.draw(s2);
        window.display();
    }
}

The attached images show how it looked before and after commit 6b71456.
TGUI: C++ SFML GUI
TGUI.Net: C# binding for TGUI

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 31883
    • View Profile
    • SFML's website
    • Email
Re: RenderTexture texture flipped after copying
« Reply #1 on: November 13, 2017, 07:52:08 pm »
Looks like we need to play with Texture::m_pixelsFlipped ::)
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 8999
    • View Profile
    • development blog
    • Email
Re: RenderTexture texture flipped after copying
« Reply #2 on: November 16, 2017, 03:58:53 pm »
Can you open an issue on GitHub, so we won't forget this?
Official FAQ: https://www.sfml-dev.org/faq.php
Nightly Builds: https://www.nightlybuilds.ch/
——————————————————————
Dev Blog: https://dev.my-gate.net/
Thor: http://www.bromeon.ch/libraries/thor/

 

anything