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

Unexpected resizing behaviour when fixing aspect ration in user code #468

Closed
mantognini opened this Issue Sep 17, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@mantognini
Member

mantognini commented Sep 17, 2013

Reported here.

SSCCE:

#include <SFML/Graphics.hpp>

int main(int argc, char* argv[])
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Resize Test");

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

            // Window Resized?
            if (event.type == sf::Event::Resized) {
                // The Window was Resized - Maintain Aspect Ratio
                float AspectX = window.getSize().x / 800.0f;
                float AspectY = window.getSize().y / 600.0f;
                // Find Which Is the smaller aspect
                if (AspectX < AspectY) {
                    //Resize Y To Fit
                    window.setSize({window.getSize().x, AspectX * 600});
                } else if (AspectX > AspectY) {
                    //Resize X To Fit
                    window.setSize({AspectY * 800, window.getSize().y});
                }
            }
        }

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

    return 0;
}

Under OS X It resizes several times a second, very quickly the window jittering between various sizes. After some time it settles on a (correct aspect) size. I have noticed that it seems to fire the window::Resized event during OS X resizing animation.

@ghost ghost assigned mantognini Sep 17, 2013

jcowgill added a commit to jcowgill/SFML that referenced this issue Sep 22, 2014

@mantognini mantognini removed their assignment Apr 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment