如何在WP8 directX app中限制FPS

时间:2013-05-06 16:23:41

标签: windows-phone-8

在某些场景中游戏似乎运行得太快, 我想将fps限制在30。 我正在使用pure-cpp d3d。 我发现WP8中没有SetWaitableTimer(我用它来限制桌面上的fps)

1 个答案:

答案 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;
}