SFML community forums

Help => Window => Topic started by: Foaly on May 29, 2012, 11:25:02 am

Title: Minor improvement
Post by: Foaly 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 :)
Title: Re: Minor improvement
Post by: Laurent 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.
Title: Re: Minor improvement
Post by: Foaly on May 29, 2012, 11:50:21 am
Ah ok I see. That makes perfect sense. Never mind. My bad…