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

Author Topic: Slow down on re-sizing the window. Is it possible to cap the speed of the progra  (Read 2902 times)

0 Members and 2 Guests are viewing this topic.

enigma22134

  • Newbie
  • *
  • Posts: 13
    • View Profile
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?


Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
« Last Edit: September 06, 2015, 05:00:36 pm by Jesper Juhl »

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
@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)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
@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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

enigma22134

  • Newbie
  • *
  • Posts: 13
    • View Profile
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. 

 

anything