Hello, made a start on a little top down game and after reading some of the excellent posts here on timing code I implemented HrdNutz timing code (thank you very much for that!). Both in windowed mode and full screen with either flip 0 or 1 it was silky smooth, didn't even notice the tiniest of glitches. Great.
So then I started on a little particle engine for it in a separate program, implemented the same timing code and it jittered all over the place, seemed ok in full screen but in windowed with flip 1 it was crazy. I couldn't understand why the game engine I was doing with the same timing code was so smooth in all modes but this wasn't.
Anyway, after process of elimination I reduced both main loops to just this:
Graphics 800,600
While Not KeyDown(KEY_ESCAPE)
Cls
dt = MilliSecs() - t
t = MilliSecs()
DrawText dt,0,0
Flip 1
Wend
When I ran this on the particle side of things dt flicks between 0, 16 and 17, so i figured it must be swings from 0 to 16/17 that's causing those jitters. The game code however simply flickered between 16/17, but why? Turns out that at some point I'd put
SetGraphicsDriver GLMax2DDriver()
in the game code and that was smoothing things out. So for some reason the dx drivers (which i assume are set as default) seem to not bother waiting for a sync every other frame. Maybe just my PC? It's Vista, maybe a dx 10 issue? I dunno, I've had enough confusion for now so I'm happy to stick with the GL drivers :)
Bizarrely, putting a delay 1 before the flip goes some way to smoothing things out.
|