SFML community forums

Help => General => Topic started by: enigma22134 on September 06, 2015, 04:44:08 pm

Title: Slow down on re-sizing the window. Is it possible to cap the speed of the progra
Post by: enigma22134 on September 06, 2015, 04:44:08 pm
Hey guys,

When I resize my window to full screen, my game runs a bit slower.


That's fine, but I was wondering if there was any way to cap the speed my game runs at a minimized screen so that it will not be faster than it running as a full screen.

I thought about putting a pause-like statement in my game loop, but I wonder if there was a better way to do this?

Title: Re: Slow down on re-sizing the window. Is it possible to cap the speed of the progra
Post by: Jesper Juhl on September 06, 2015, 04:58:58 pm
http://www.sfml-dev.org/documentation/2.3/classsf_1_1Window.php#af4322d315baf93405bf0d5087ad5e784

You probably also want to read this: http://gafferongames.com/game-physics/fix-your-timestep/
Title: Re: Slow down on re-sizing the window. Is it possible to cap the speed of the progra
Post by: dabbertorres on September 06, 2015, 08:05:31 pm
One option I've seen some games do is simply pause the game while the window is being resized, until the user unpauses. Personally, I think that's a good option.
Title: Re: Slow down on re-sizing the window. Is it possible to cap the speed of the progra
Post by: Hapax on September 08, 2015, 12:42:54 am
@dabbertorres, how does one test to see if the window is being resized?

I would say that using the timestep methods shows in Jesper's second link and pausing if the time accumulated becoming too large would be a decent choice here.

(Jesper answered the actual question fully, by the way  ;D)
Title: Re: Slow down on re-sizing the window. Is it possible to cap the speed of the progra
Post by: dabbertorres on September 08, 2015, 03:41:19 am
@dabbertorres, how does one test to see if the window is being resized?
http://www.sfml-dev.org/documentation/2.3/structsf_1_1Event_1_1SizeEvent.php
A resize event is generated on the first size change of the window iirc. If not, then handle a MouseLeft event. Different event, but same result generally. I know it's one of those, as I've done it before.

Though it looks like I completely misunderstood the question now that I've read it again, haha. I thought he was complaining about the game window lagging while resizing the window, my bad.
Title: Re: Slow down on re-sizing the window. Is it possible to cap the speed of the progra
Post by: Hapax on September 08, 2015, 01:09:47 pm
A resize event is generated on the first size change of the window iirc.
Ah, I see where your answer came from. However, the resize event is only generated once the resizing of the window has been completed.
Title: Re: Slow down on re-sizing the window. Is it possible to cap the speed of the progra
Post by: enigma22134 on September 14, 2015, 09:28:14 pm
Thanks for all the replies, they really helped! For now, I'm going to try and limit the frame rate. That seems like the quick fix, but I will probably have to get a bit more into it later.