SFML community forums

Help => Window => Topic started by: Hydra on August 21, 2015, 12:54:12 pm

Title: Window resizing?
Post by: Hydra on August 21, 2015, 12:54:12 pm
I've recently started using SFML and it's great. I've got one problem with it though. In for example Java when creating a window and resizing it the objects inside the window will stay the same size. But in SFML it automatically resizes to fit the screen. Creating a stretched ugly mess I've looked online yet can't find anywhere that lets you disable the window resizing like this?
Title: Re: Window resizing?
Post by: Jesper Juhl on August 21, 2015, 01:00:32 pm
A sf::View can be used to scale stuff.
Title: Re: Window resizing?
Post by: Hydra on August 21, 2015, 01:05:51 pm
+Jesper Juhl

So is there no way to disable the resizing? It seems more like an annoyance than a feature of SFML.
Title: Re: Window resizing?
Post by: Satus on August 21, 2015, 02:03:07 pm
+Jesper Juhl

So is there no way to disable the resizing? It seems more like an annoyance than a feature of SFML.

Get sf::View from window.getDefaultView(), call window.setView() and pass it your received view.
Also stackoverflow (http://stackoverflow.com/questions/27785940/shapes-proportionally-resize-with-window-in-sfml-2-x)
Wiki tutorial on View: https://github.com/SFML/SFML/wiki/Tutorial:-Using-View (https://github.com/SFML/SFML/wiki/Tutorial:-Using-View)
Title: Re: Window resizing?
Post by: Verra on August 21, 2015, 05:56:59 pm
If you don't want resizing you can pass the style flag sf::Style::Close.
Title: Re: Window resizing?
Post by: Laurent on August 21, 2015, 08:57:16 pm
Seriously...

http://www.sfml-dev.org/tutorials/2.3/graphics-view.php#showing-more-when-the-window-is-resized
Title: Re: Window resizing?
Post by: Mithra on November 17, 2015, 01:50:43 am
Perfect, thank you Laurent!  I was having the same problem.
Title: Re: Window resizing?
Post by: mkalex777 on November 17, 2015, 02:37:10 am
Just use View and set it's size to window size at beginning of render loop. That's all what you need. So you don't need to handle resize event, because your view size will be always correct, even when resize event will not be raised
Title: Re: Window resizing?
Post by: Laurent on November 17, 2015, 08:53:29 am
Quote
Just use View and set it's size to window size at beginning of render loop
How is that better than doing it only when the Resized event is triggered, ie. only when it makes sense?
Title: Re: Window resizing?
Post by: mkalex777 on November 18, 2015, 09:07:33 am
Quote
Just use View and set it's size to window size at beginning of render loop
How is that better than doing it only when the Resized event is triggered, ie. only when it makes sense?

I think that it's better because the code will be short and transparent, it will be better to understand, because it means that view size is always the same as window size :)
Title: Re: Window resizing?
Post by: shadowmouse on November 18, 2015, 09:18:23 am
But the view size will always be the same as the window size if you set it to the window size upon a Resized event. It also means that the view isn't being changed constantly, and the code for changing the size of the view is clearly under an if that states that it is the code for coping with the resizing of the window, which means it explicitly states what it does, why it does it and it will have the better performance.