how to keep aspect ratio sfml

Solutions on MaxInterview for how to keep aspect ratio sfml by the best coders in the world

showing results for - "how to keep aspect ratio sfml"
Giovanni
31 Feb 2019
1// the event loop
2sf::Event event;
3while (window.pollEvent(event))
4{
5    ...
6
7    // catch the resize events
8    if (event.type == sf::Event::Resized)
9    {
10        // update the view to the new size of the window
11        sf::FloatRect visibleArea(0, 0, event.size.width, event.size.height);
12        window.setView(sf::View(visibleArea));
13    }
14}
15