Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed RenderTexture being upside down on Android in SFML 2.6 (backport of #2719) #2730

Merged

Conversation

texus
Copy link
Contributor

@texus texus commented Oct 9, 2023

This fixes #2419 on the 2.6.x branch

The fix was already merged in the master branch with #2719, this is a backport for the 2.6.x branch

How to test this PR?

The following code is supposed to render a green circle in the top left corner of the screen.
On Android, before the change from this PR is applied, the green circle will appear in the bottom left corner instead.

#include <SFML/Graphics.hpp>
int main()
{
    sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "SFML works!", sf::Style::Fullscreen);

    sf::CircleShape circle(400.f);
    circle.setFillColor(sf::Color::Green);

    sf::RenderTexture texture;
    texture.create(window.getSize().x, window.getSize().y);

    texture.clear();
    texture.draw(circle);
    texture.display();

    sf::Texture copiedTexture = texture.getTexture();
    sf::Sprite sprite(copiedTexture);

    bool active = window.hasFocus();
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            switch (event.type)
            {
            case sf::Event::Closed:
                window.close();
                break;
            case sf::Event::LostFocus:
                window.setActive(0);
                active = 0;
                break;
            case sf::Event::GainedFocus:
                window.setActive(1);
                active = 1;
                break;
            case sf::Event::KeyReleased:
                if (event.key.code == sf::Keyboard::Escape)
                    window.close();
                break;
            }
        }
        if (!active)
            continue;

        window.clear();
        window.draw(sprite);
        window.display();
    }
}

@ChrisThrasher
Copy link
Member

ChrisThrasher commented Oct 9, 2023

I know you already tested #2719 but can you also please test this on your device? I'd like to be certain that the fix is still valid when applied to this other branch.

@texus
Copy link
Contributor Author

texus commented Oct 10, 2023

To be clear, I did retest the issue and solution on the 2.6 branch before making the PR, I didn't just copy the code without checking.
Nevertheless it is always best if someone else can independently verify that it works as well.

Copy link

@Zombieschannel Zombieschannel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works, it works, I'm sorry I'm late 😅

@ChrisThrasher ChrisThrasher merged commit 13c8a1d into SFML:2.6.x Oct 12, 2023
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants