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

Author Topic: Minor improvement  (Read 1320 times)

0 Members and 1 Guest are viewing this topic.

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Minor improvement
« on: May 29, 2012, 11:25:02 am »
For whatever reason I was looking at the window source code the other day and I noticed a little thing that made me wonder. In line 336 (the display function) the time of the clock is requested and in the next line the clock is restarted.
I read somewhere (either the doc or a forum post) that it's better to just use the restart function, because it also returns the elapsed time and you skip the delay between the two function calls.
Is there a specific reason you don't use only restart? I was just wondering. I know this really is a minor thing :)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Minor improvement
« Reply #1 on: May 29, 2012, 11:41:44 am »
Yes, there's a good reason: the clock must be restarted after the pause, so that the "wait" time of the current frame is not counted in the next frame's duration.
Laurent Gomila - SFML developer

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: Minor improvement
« Reply #2 on: May 29, 2012, 11:50:21 am »
Ah ok I see. That makes perfect sense. Never mind. My bad…