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

Re: [pygame] recap: refresh rate and timing issues



What if you do 2 flip calls and then maintain 60 fps (or whatever your refresh rate is) from then on?
(I'm thinking that the second flip call will block until the first is done - I think most drivers behave that way so they don't get too far ahead)


On Tue, Feb 10, 2009 at 2:22 AM, Matthias Treder <matthias4all@xxxxxxxxxxxxxx> wrote:
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