OpenGL 帧率

标签 opengl frame-rate

测量 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/

相关文章:

c++ - 如何在 Visual Studio 界面中创建 "Shader"文件夹

c++ - 无法在 openGL 和 GLUT 中为我想要的确切对象制作动画

OpenGL 4.4 管道 - 裁剪前的透视划分?

c# - XNA/MonoGame : Getting the Frames Per Second

Java游戏: Keeping framerate the same on all computers

android - Box2D Physics 是否依赖帧率?

opengl - 无法理解合并实例的概念

c++ - glGetAttribLocation() 返回 -1 但变量是统一的,如何解决?

Android - 如何衡量 ListView 和其他 View 的性能?

javascript - 如何在 HTML-Canvas 上渲染光线转换的墙壁纹理