I am trying to figure out why this FPS limit doesn't works properly on some computers.. for example when I limit the fps to 333 it will show 250 and on some computers the FPS limitation will work just fine (when limit 333 it will limit 333 and not 250 or any other number).
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;
}