Weird GetTickCount behavior
This is pretty weird, I use GetTichCount to find the elapsed time, but I always seem to get a number divisible by 10ms??? When I output the ms elapsed for one frame I would get something like 40 or 50 switching in between each of them (with the VERY occasional 49 or 41), faster execution would give 20 -30, slower, 60 -70 and so on, but always divisible by 10! (fastest would be 10, on the dot!) It must be something I''m doing wrong somewhere, maybe in my conversions, but I want to know if anyone ever got the same problem before... It''s been bugging me for a long time now and it bugs me even more since I remember ONCE being able to do it correctly a long time ago...
I''m not quite sure that GetTickCount is actually accurate to 1ms, but a better alternative would to use either the Performance counter (via QueryPerformanceCounter() etc.) or the multimedia timer. Look it up in MSDN.
Are you calling GetTickCount in the WinMain loop? Is there any other delay in the loop?
========
Smidge
www.smidge-tech.co.uk
========
Are you calling GetTickCount in the WinMain loop? Is there any other delay in the loop?
========
Smidge
www.smidge-tech.co.uk
========
--Mr Smidge
ok, I did a bit of research, apparently, win 2000 has a timer resolution of 5ms or more, win 95 has 1 ms res, win98 (???) but I assume the first edition is 1 ms, the second is 5 or more (I have a friend who tried it and it did the same as me, he run win 98 2nd)
Anyway, this is what I had before
timedelta = GetTickCount() - timebuffer;
timebuffer = GetTickCount();
and now
timeEndPeriod(1); // 1 for 1 ms resolution
timedelta = timeGetTime() - timebuffer;
timebuffer = timeGetTime();
timeBeginPeriod(1);
weird thing is they say that you have to put timeBeginPeriod(1); before and put timeEndPeriod(1); after, but when I do, it has no effect??? (I exactly inverse the 2)
Good luck solving THAT mystery...
Thanks for your help
Anyway, this is what I had before
timedelta = GetTickCount() - timebuffer;
timebuffer = GetTickCount();
and now
timeEndPeriod(1); // 1 for 1 ms resolution
timedelta = timeGetTime() - timebuffer;
timebuffer = timeGetTime();
timeBeginPeriod(1);
weird thing is they say that you have to put timeBeginPeriod(1); before and put timeEndPeriod(1); after, but when I do, it has no effect??? (I exactly inverse the 2)
Good luck solving THAT mystery...
Thanks for your help
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement