我有一个游戏公共资源,并且FPS Limiter在Windows 10中失败了。 例如,如果我将g_nFrameLimitValue更改为333,则此限制为280,如果我尝试限制为250,则得到209.我仅在Windows 10中出现这些问题。(Windows 8我不确定,7工作正常)。< / p>
以下代码:
void OnUpdate()
{
{
g_nFrameCount++;
DWORD currentTime=timeGetTime();
{ // 1ÃÊ´ç ÇÁ·¹ÀÓ Á¦ÇÑ (Á¦ÇÑ Á¾·ù: ¹«Á¦ÇÑ, 60fps, 120fps, 240fps)
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;
}
}
}