Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How do I maximize my window without changing how big sprites look?  (Read 3241 times)

0 Members and 1 Guest are viewing this topic.

Chuckleluck

  • Jr. Member
  • **
  • Posts: 52
    • View Profile
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. 

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: How do I maximize my window without changing how big sprites look?
« Reply #1 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

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11029
    • View Profile
    • development blog
    • Email
Re: How do I maximize my window without changing how big sprites look?
« Reply #2 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(...)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything