开发者

Firefox interacts with my timers somehow ?!?! This is crazy ^^

开发者 https://www.devze.com 2023-02-26 01:31 出处:网络
I have a problem with the timers in my win32 C++ DirectX game (a little demo). I am using \"timeGetTime\" to get the current time and use it to playback the animations or for logic by using the delta

I have a problem with the timers in my win32 C++ DirectX game (a little demo). I am using "timeGetTime" to get the current time and use it to playback the animations or for logic by using the delta time (I also use a constant for normalization when animating). I use a tickrate as low as 2 miliseconds sometimes. I am using only ULONGs when working with time. The game works just fine, but if I start Mozilla 开发者_Python百科Firefox and I start the game after all is playing very fast (the animations and the game logic). It's like fast forwarding. The strange thing is that it seems that a few timers are not affected by this. Does someone have a clue ? What is the connection between Firefox and my timers ? After exiting Firefox is stays the same, but after some undefined time or a PC restart it goes back to normal. Any suggestions are appreciated, even if it is a long shot. Thank you.


Yes the default precision of TimeGetTIme is 5ms or more.

This can be altered with the calls timeBeginPeriod and timeEndPeriod functions. Alterning the precision of TimeGetTime affects all running applications. I guess Firefox is calling those functions which affect your application.

Change to use the QueryPerformanceCounter/QueryPerformanceFrequency methods instead which provide high res timing and will not be subject to the issues of TimeGetTime.

EDIT: A couple of links that show you how to use the functions.

http://www.programmersheaven.com/mb/windows/311148/311148/using-queryperformancecounter/

And also note the remarks on the MSDN page: http://msdn.microsoft.com/en-us/library/ms644904(v=vs.85).aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消