First please read my older post in which I thought I fixed it. (skip if you don't have time)
Firefox interacts with my timers somehow ?!?! This is crazy ^^
For those who do not want to read, I'll just sum it up: Firefox messes my timers when it is running so I had to switch from timeGetTime() to QueryPerformanceCounter(), as recommended by the stackoverflow members.. And it is still subjected to the same problem (firefox running makes everything 'fast forwarded'). And I don't understand why now. Maybe I am messing somehow here:
ULONG CTimer::time()
{
开发者_Go百科 __int64 temp;
QueryPerformanceCounter((LARGE_INTEGER*)&temp);
return (ULONG)(temp*1000/freq);
}
// where freq is the one queried with QueryPerformanceFrequency()
Anybody has any idea ? Also any tips are welcomed.
How are you calculating motion? If you accurately calculate delta-time (the time since the last tick) with QueryPerformanceCounter, and calculate motion based on that, you should be fine. So the distance each object moves per tick should be deltatime * speed.
My best guess is you're not doing that, and instead it's based on the framerate, and the framerate changes when you open Firefox (for whatever reason). Showing your code would be helpful.
One more thing - QueryPerformanceCounter/Frequency may be different for different cores - is your application multithreaded? If so, opening Firefox may cause Windows shift your application to executing a different core, where QueryPerformanceCounter/Frequency are different. You must make sure you always call them from the same processor core (set the processor affinity on the thread that calls them).
Firefox itself doesn't mess around with the high performance timers, so the result of such things as setInterval depends on whether something else, such as Google Chrome, does.
精彩评论