我试图弄清楚为什么这个FPS限制在某些计算机上无法正常运行...例如,当我将fps限制为333时它将显示250并且在某些计算机上FPS限制将正常工作(当限制时) 333它将限制333而不是250或任何其他数字。)
g_nFrameCount++;
DWORD currentTime = timeGetTime();
{
float fFrameLimit = 0;
if (g_nFrameLimitValue > 0)
fFrameLimit = 1000 / g_nFrameLimitValue;
if ((currentTime - g_dwLastTime) < fFrameLimit)
{
Sleep((int)fFrameLimit - (currentTime - g_dwLastTime));
currentTime = timeGetTime();
}
g_dwLastTime = currentTime;
}
if (g_dwLastFPSTime + FPS_INTERVAL<currentTime)
{
g_fFPS = (g_nFrameCount - g_nLastFrameCount)*FPS_INTERVAL / ((float)(currentTime - g_dwLastFPSTime)*(FPS_INTERVAL / 1000));
g_dwLastFPSTime = currentTime;
g_nLastFrameCount = g_nFrameCount;
}