From: Ikke on
"winapi" <apiwin(a)hotmail.com> wrote in
news:ho1088$3pq$1(a)speranza.aioe.org:

> The reason your animation is jerky, is that you can only update in
> increments of
> "one" using the GDI. If you have noticed, coordinates use integer
> values, so the best you can hope for, is an increment of += 1, not +=
> 0.1. This is not possible. if you try, you will see your shape remains
> static.You might want
> to try GDI+, this will give you better results than the standard GDI.
>
> See example code below, just change SetTimer value of 1000(one second)
> to what ever. You will why the animation is jery using GDI . . . . .

Thanks for the explanation - I realise that the movement of the ellipse
will always be in increments of 1 (never smaller), but that's not the
type of jerkiness I was experiencing.

It was more of an impression that, from time to time, the ellipse got
"stuck" behind something. As in your code example, the cube moves 1 pixel
every second. Suppose it would move 1 pixel the next ten seconds, and
then suddenly move 1 pixel after 1.5 seconds, you'd notice the delay.
That's the jerkiness I was experiencing.

Anyway, I changed my code to use the QueryPerformanceCounter (like Scott
said), and the improvement is incredible!

The increments are of course still per pixel, but the timing is a lot
more accurate.

Thanks!

Ikke
From: winapi on
Well, that will teach me for browsing over code. It seems your code is taken
care of the incremental update to give that smoothness. Sorry for my
misleading comments,
seems I should pay more attention. I wonder if timeGetTime() would work
also, although
QueryPerformanceCounter is obviously better.

"Ikke" <ikke(a)hier.be> wrote in message
news:Xns9D41B2D496E75ikkehierbe(a)69.16.176.253...
> N0Spam(a)daqarta.com (Bob Masta) wrote in news:4ba2257d.396212(a)news.eternal-
> september.org:
>
> <snip>
>>>QueryPerformanceCounter updates vastly faster. You will initially
>>>have to use QueryPerformanceFrequency to translate into time periods:
>>>They differ on different machines.
>>>
>> Another approach is to use a multi-media timer
>> (timeBeginPeriod, timeSetEvent, etc.), which can
>> be set to fire every msec. <snip>
>
> Thank you Scott and Bob, I have changed my code to use the
> QueryPerformanceCounter, and I added a variable onscreen to check the
> improvement.
>
> When I used GetTickCount, the ellipse would be moved (on average) 65 times
> per second (like you said, Scott, every 15 ms). As soon as I switched to
> QueryPerformanceCounter, the movement become very fluent, and the ellipse
> is being moved at a rate of 995 times per second!
>
> Thanks again,
>
> Ikke


From: Ikke on
"winapi" <apiwin(a)hotmail.com> wrote in
news:ho39p2$np9$1(a)speranza.aioe.org:

> Well, that will teach me for browsing over code. It seems your code is
> taken care of the incremental update to give that smoothness. Sorry
> for my misleading comments,
> seems I should pay more attention. I wonder if timeGetTime() would
> work also, although
> QueryPerformanceCounter is obviously better.

No problem - all comments are welcome!

I don't know whether or not timeGetTime() works, I haven't tried it (yet).

Thanks,

Ikke