[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] recap: refresh rate and timing issues



Hi guys.
There was a thread about this issue in 2007, with no obvious solution.
I got the same problem so I hope somebody knows a way out (if any).
The point is I want to know exactly when a flip is occuring. Naive
code could look like this :

.... do some drawing here ....
pygame.display.flip()
timestamp = pygame.time.get_ticks()

With double buffering, the flip waits for the next screen refresh, but
the program is not blocking and waiting for the flip (which is quite
reasonable), it just goes on. This means, however, that get_ticks()
will probably return before the actual flip happened. With my screen
(60 Hz), there is thus an unpredictable error of 0 - 16.6 ms.
Is there any way to get to know when the flip happened, or at least to
reduce this error below 10ms or so?

Thanks.
Matthias