opentk/opentk — pull request #32 by thefiddler (2014-01-07 14:05:03+00:00)
Title: Improve GameWindow timing (fixes issue #20)

This PR simplifies and improves the timing calculations for GameWindow.UpdateFrame and RenderFrame events.

A single, monotonically increasing Stopwatch is now used for timing calculations. Calculated timespans are clamped to the [0.0, 1.0] range to protect against various conditions (system entering sleep, debugger break, changing timezones.) Precision loss over longer timespans should be acceptable for several weeks of uptime.

This PR finally correctly implements Update/RenderPeriod, Update/RenderFrequency and Update/RenderTime. GameWindowStates will now display these values, as well as the timing drift for UpdateFrame and RenderFrame events (this should be constant.)

We should investigate under which conditions we can/should reset the Stopwatch, once we add Pause/Resume events in post-1.1 versions.