0

游戏在某些场景中似乎运行得太快,我想将 fps 限制在 30。我使用的是纯 cpp d3d。我发现 SetWaitableTimer 在 WP8 中不可用(我用它来限制桌面中的 fps)

4

1 回答 1

0

SleepConditionVariableCS 在 WP8 中可用,这里是 sleep 的代码

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;
}
于 2013-05-07T09:03:10.783 回答