New method for limited frame speed in the game

zhaozj2021-02-08  272

Previously, many methods introduced by using GetTickCount / or multimedia timer, to train time, accurate is really good. But this will cause great waste of CPU time, one main manifestation is that the background procedure is extremely slow in the NT / 2000 environment. If you can use a method like Win32 WaitObject, the thread hangs, the CUP resource is wasteful when waiting time message. This will not have problems hanging from the background program.

Fortunately, Win32 offers WAITable Timer to wait for Time Event. Please refer to MSDN for details.

What to say here is that the default accuracy of Waitable Timer is 1/50 seconds, less than 60FPS requirements. Nothing to check MSDN has found a function that can set time accuracy.

Later, in an accidental opportunity I found that the TimerBeginPeriod () function sets multimedia time accuracy to affect Waitable Timer. Guess Waitable Timer is implemented using a multimedia clock. You can get a time message per second by setting TimerBeginPeriod (8). A larger value will make the CPU usually improve, so it is recommended to set it to the precision required.

转载请注明原文地址:https://www.9cbs.com/read-1950.html

New Post(0)