C ++:计算游戏中的总帧数 [英] C++: Counting total frames in a game

查看:1598
本文介绍了C ++:计算游戏中的总帧数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不是一个很好的标题,但我不知道该命名它。



无论如何,我计算的总帧数FPS)在我的游戏中与 long int 。为了万一游戏持续很长时间,我应该怎么做,以确保我的 long int 没有增加超过其限制?



感谢。

解决方案

整个游戏的整个长度的平均FPS似乎不是一个非常有用的统计。通常,您将希望测量峰值和谷值,例如最高fps /最低fps和低于和高于阈值的帧数。

在现实中,我不会担心。即使你只是使用一个32位unsigned int,你的游戏可以运行在60fps的1988年4小时之前,它会溢出。您应该很好。



编辑:



在这种情况下检测溢出的最好方法是检查和查看整数在递增后是否减小。如果是这样,你可以只保留另一个计数器,即你溢出的次数。


Not a very good title, but I didn't know what to name it.

Anyway, I am counting the total frames (so I can calculate an average FPS) in my game with a long int. Just in case the game went on reallly long, what should I do to make sure my long int doesn't get incremented past its limit? And what would happen if it did go past its limit?

Thanks.

解决方案

Average FPS throughout the length of an entire game doesn't seem to be a very useful statistic. Typically you will wish to measure peaks and valleys, such as highest fps / lowest fps and amount of frames spent below and above threshold values.

In reality though, I would not worry. Even if you were to just use a 32 bit unsigned int, your game could run at 60fps for 19884 hours before it would overflow. You should be fine.

EDIT:

The best way to detect overflow in this case is to check and see if the integer decreased in value after being incremented. If so, you could just keep another counter around which is the number of times you have overflowed.

这篇关于C ++:计算游戏中的总帧数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆