[英]60 FPS Game Loop on Universal Windows Platform Direct3D C++ App
Windows的C ++方面非常新颖-特殊的非Win32,例如UWP-
我试图通过简单地每1000/60毫秒勾选(更新/渲染)来将FPS限制在稳定的60 FPS。 我虽然面临一个奇怪的情况。 如果我使用Present(0,0),交换链将自动锁定并垂直同步,一切都很好。 如果我使用Present1(0,DXGI_PRESENT_DO_NOT_WAIT,&params)...我达到了600 FPS ...
现在,在让FPS免费(600)的同时,我想实现自己的代码。 到目前为止,我有:
bool Ticker::Tick() {
long currentTick = GetTickCount64();
long deltaTicks = (currentTick - gLastTick);
bool tick = false;
// determine whether it is tick time
if (deltaTicks >= gUpdateTime) {
gLastTick = currentTick;
gTicksCount++;
char buf[256];
sprintf_s(buf, "Current delta: %30d\n", deltaTicks);
OutputDebugStringA(buf);
tick = true;
}
// this metric must happen regardless of actual true Ticks
if (currentTick - gSecondTime >= 1000) {
gCurrentFrameRate = gTicksCount;
gSecondTime = currentTick;
OutputDebugStringW(L"Second is up\n");
gTicksCount = 0;
}
return tick;
}
不用说这是行不通的...我的目标是刷新非常1000/60时,我达到了20/21 FPS。
我相信我犯了一个相当愚蠢的错误,但是我看不到哪里。
谢谢。
从文档中:
GetTickCount64函数的分辨率限于系统计时器的分辨率,通常在10毫秒到16毫秒的范围内。
因此在1000/60〜15ms时,计数器分辨率不足。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.