在某些场景中游戏似乎运行得太快, 我想将fps限制在30。 我正在使用pure-cpp d3d。 我发现WP8中没有SetWaitableTimer(我用它来限制桌面上的fps)
答案 0 :(得分:0)
Sleep88ditionVariableCS在WP8中可用,这里是睡眠代码
struct WaitTimeData
{
CONDITION_VARIABLE conditionVariable;
CRITICAL_SECTION criticalSection;
WaitTimeData()
{
InitializeConditionVariable(&conditionVariable);
memset(&criticalSection , 0 , sizeof(CRITICAL_SECTION));
//InitializeCriticalSection(&_CriticalSection); wp8 has no this func
criticalSection.DebugInfo = (PRTL_CRITICAL_SECTION_DEBUG)-1;
criticalSection.LockCount = -1;
}
};
int WPSleep(unsigned int ms)
{
static WaitTimeData s_wtd;
SleepConditionVariableCS(
&s_wtd.conditionVariable,
&s_wtd.criticalSection,
ms
);
if (GetLastError() == ERROR_TIMEOUT)
{
SetLastError(0);
}
return 0;
}