SFML community forums

Help => Window => Topic started by: paulj91 on June 02, 2013, 08:56:45 am

Title: Resizing Oversized Windows
Post by: paulj91 on June 02, 2013, 08:56:45 am
I have been looking into supporting different screen resolutions with SFML, with which I don't have a lot of experience. In order to do this, I decided to opt for a 1920x1024 resolution, then scale to the appropriate resolution accordingly by changing the size of the window. However, I've been running into a bit of a problem. The following code doesn't actually resize the window that is created with its call to setSize;

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
int main(){
  sf::RenderWindow w(sf::VideoMode(1920,1024,32),"Window");
  w.setSize(sf::Vector2u(800,600));
  w.display();
  sf::sleep(sf::seconds(5));
}
 

I know that oversized windows do not display properly due to OS restrictions, but does this also prevent them from being resized? If so, what is the best way to handle resolutions that are larger than the development screen size? Thanks so much, any help or input would be much appreciated.
Title: Re: Resizing Oversized Windows
Post by: Laurent on June 02, 2013, 09:40:51 am
You probably need an event loop if you want something to happen to your window, instead of blocking the application with sf::sleep.
Title: Re: Resizing Oversized Windows
Post by: paulj91 on June 02, 2013, 10:01:52 am
By event loop do you just mean polling for events? I suppose I could look for Resize events, though other than adjusting the size like in the first example, I can't think of any other actions that I should take in order to resize the window. Even with an empty loop polling for events, there is no window resize taking place.

#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

int main(){
  sf::RenderWindow w(sf::VideoMode(1920,1024,32),"Window");
  w.setSize(sf::Vector2u(800,600));
  w.display();
  sf::Event event;
  while (w.isOpen()){
    w.clear();
    while (w.pollEvent(event)){
     
    }
    w.display();
  }
}  
 

Is this roughly what you meant by an event loop being necessary? This code doesn't work either, and this is just a minimal example I could provide that reproduces the issue. I apologize if I am forgetting something simple, I just can't seem to figure out why resetting the size isn't resizing the window.
Title: Re: Resizing Oversized Windows
Post by: Laurent on June 02, 2013, 11:06:23 am
Yes, this is what I meant.

Windows are known to behave strangely on Windows when there initial size is bigger than the desktop resolution. So this might be "normal".
Title: Re: Resizing Oversized Windows
Post by: paulj91 on June 02, 2013, 09:18:26 pm
Awesome, thanks! The test machine this was built on runs Ubuntu, so it seems like window managers in general might have a problem with it. Thanks for all the help, I'll look into alternative methods!