gpt4 book ai didi

C++:计算移动 FPS

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:08:34 25 4
gpt4 key购买 nike

我想计算游戏最后 2-4 秒的 FPS。执行此操作的最佳方法是什么?

谢谢。

编辑:更具体地说,我只能访问一个以一秒为增量的计时器。

最佳答案

差点错过最近的帖子。请参阅我对使用指数加权移动平均线的回复。

C++: Counting total frames in a game

这是示例代码。

最初:

avgFps = 1.0; // Initial value should be an estimate, but doesn't matter much.

每秒(假设最后一秒的总帧数在framesThisSecond中):

// Choose alpha depending on how fast or slow you want old averages to decay.
// 0.9 is usually a good choice.
avgFps = alpha * avgFps + (1.0 - alpha) * framesThisSecond;

关于C++:计算移动 FPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4687430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com