Two questions: I noticed that it takes a couple of buffer flips for things to synchronize with the display frequency (on my system the display frequency is around 60 Hz). Does anyone know why this is?
By what mechanism does FlipBuffers() know that VSync has arrived?
If anyone has any suggestions for improvements, please feel free to suggest.
Code: Select all
DisableDebugger
Dim duration.f(20)
OpenConsole()
QueryPerformanceFrequency_(@maxFreq): maxFreq / 1000
InitSprite()
;OpenScreen(1024, 768, 32, "", #PB_Screen_NoSynchronization)
OpenScreen(1024, 768, 32, "", #PB_Screen_WaitSynchronization)
;IT MAY TAKE A FEW BUFFER FLIPS TO GET SYNCHRONIZED
For ct = 1 To 20
FlipBuffers()
Next
For ct = 1 To 20
QueryPerformanceCounter_(@then.q)
FlipBuffers()
QueryPerformanceCounter_(@now.q)
duration(ct) = (now - then) / maxFreq
Next
CloseScreen()
For ct = 1 To 20
PrintN(StrF(duration(ct),2) + " ms" + Chr(9) + StrF(1/duration(ct)*1000,2) + " frames per second")
Next
PrintN(Chr(10) + "Press any key to exit."): While Inkey() = "": Delay(5): Wend: CloseConsole()
End