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

Author Topic: Resizing Oversized Windows  (Read 1884 times)

0 Members and 1 Guest are viewing this topic.

paulj91

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Resizing Oversized Windows
« 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.
« Last Edit: June 02, 2013, 09:56:30 am by paulj91 »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Resizing Oversized Windows
« Reply #1 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.
Laurent Gomila - SFML developer

paulj91

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Resizing Oversized Windows
« Reply #2 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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Resizing Oversized Windows
« Reply #3 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".
Laurent Gomila - SFML developer

paulj91

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: Resizing Oversized Windows
« Reply #4 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!