如何计算FPS在OpenGL? [英] How to calculate FPS in OpenGL?
本文介绍了如何计算FPS在OpenGL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
void CalculateFrameRate()
{
static float framesPerSecond = 0.0f; // This will store our fps
static float lastTime = 0.0f; // This will hold the time from the last frame
float currentTime = GetTickCount() * 0.001f;
++framesPerSecond;
if( currentTime - lastTime > 1.0f )
{
lastTime = currentTime;
if(SHOW_FPS == 1) fprintf(stderr, "\nCurrent Frames Per Second: %d\n\n", (int)framesPerSecond);
framesPerSecond = 0;
}
}
我应该在调用此函数无效播放(无效)
或无效显示(无效)
?
,或不作任何区别?
推荐答案
您应该把它放在显示屏循环。 这里的,解释游戏的一些错综复杂的文章循环,你应该阅读。
You should put it in the display loop. Here's an article that explains some intricacies of game loops that you should read.
这篇关于如何计算FPS在OpenGL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文