SFML community forums

Help => Window => Topic started by: Chuckleluck on April 18, 2012, 09:06:03 pm

Title: How do I maximize my window without changing how big sprites look?
Post by: Chuckleluck on April 18, 2012, 09:06:03 pm
Hello,
Is there a function (in SFML 2) that will allow me to maximize/resize my window without changing how big the sprites look onscreen?

Thanks in advance. 
Title: Re: How do I maximize my window without changing how big sprites look?
Post by: Lo-X on April 18, 2012, 09:07:35 pm
I think that's because the view associated tothe window and on witch you draw your sprite isn't resized.

try to resize the view when the window's size change
Title: Re: How do I maximize my window without changing how big sprites look?
Post by: eXpl0it3r on April 19, 2012, 12:14:20 am
As Lo-X said you'll have to update the size of the sf::View or your sf::RenderWindow.

That's what I've implemented in my code:
        sf::Vector2f size = static_cast<sf::Vector2f>(mWindow.getSize());

        // Minimum size
        if(size.x < 800)
                size.x = 800;
        if(size.y < 600)
                size.y = 600;

        mWindow.setSize(static_cast<sf::Vector2u>(size));
        mWindow.setView(sf::View(sf::FloatRect(0.f, 0.f, size.x, size.y)));
It gets called whenever the resize event (event.type == sf::Event::Resized) is fired.

But keep in mind, if you want to change to fullscreen mode, you'll have to 'create a new videomode' with window.create(...)