测量 OpenGL 程序帧速率的最佳方法是什么?
最佳答案
在主循环的开始处放置一个计时器并测试返回那里需要多长时间。
在 Windows 下,您会执行以下操作:
double oldTime = 0.0.
while( !exit )
{
__int64 counter;
QueryPerformanceCounter( (LARGE_INTEGER*)&counter );
__int64 frequency;
QueryPerformanceFrequency( (LARGE_INTEGER*)&frequency );
double newTime = (double)counter / (double)frequency;
double frameRate = 1.0 / (newTime - oldTime);
oldTime = newTime;
// Rest of your game loop goes here.
}
关于OpenGL 帧率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1370361/