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

Author Topic: Window lag messing with data using timers  (Read 1309 times)

0 Members and 1 Guest are viewing this topic.

replicant

  • Newbie
  • *
  • Posts: 18
    • View Profile
Window lag messing with data using timers
« on: November 02, 2011, 10:34:05 am »
When you select the window, hold it and drag it around, the application freezes. This is fine except for data which uses sf::Clock or GetFrameTime().

I have a background which moves stars across the screen using GetFrameTime(). Once they go off screen, The main loop moves them back to the starting side.

Looks like this normally.


However if you freeze the window, the timer still increases which results in them all instantly moving off screen and this ruins the background.

After freezing the window.


Is there anyway I can pause sf::Clock before freezing the application and then unpause upon unfreezing? or any other way around this? do I need to use threads?

SFML-2.0-512a7c6
Windows 7 64b
ATI Radeon HD 4850

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Window lag messing with data using timers
« Reply #1 on: November 02, 2011, 10:51:15 am »
There are several solutions to this problem:
- use Thor clocks, they can be paused
- never reset the position of the stars, apply a modulo only when you display them to make them fit in the window
- ignore huge frame times (> 1 sec)

Nice intro screen, by the way :)
Laurent Gomila - SFML developer

replicant

  • Newbie
  • *
  • Posts: 18
    • View Profile
Window lag messing with data using timers
« Reply #2 on: November 02, 2011, 11:45:07 am »
Quote from: "Laurent"
There are several solutions to this problem:
- use Thor clocks, they can be paused
- never reset the position of the stars, apply a modulo only when you display them to make them fit in the window
- ignore huge frame times (> 1 sec)

Nice intro screen, by the way :)


Thanks.  :)

Going to look into Thor and the second solution is interesting, I did think of the third but it seemed a bit hackish to me.