惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
AI
AI
T
Threatpost
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
Scott Helme
Scott Helme
AWS News Blog
AWS News Blog
P
Privacy & Cybersecurity Law Blog
G
GRAHAM CLULEY
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
Cyberwarzone
Cyberwarzone
NISL@THU
NISL@THU
P
Privacy International News Feed
Schneier on Security
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
SecWiki News
SecWiki News
T
Tor Project blog
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Troy Hunt's Blog
Cisco Talos Blog
Cisco Talos Blog
人人都是产品经理
人人都是产品经理
腾讯CDC
博客园 - 【当耐特】
Engineering at Meta
Engineering at Meta
The Hacker News
The Hacker News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
PCI Perspectives
PCI Perspectives
罗磊的独立博客
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
TaoSecurity Blog
TaoSecurity Blog
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Threat Research - Cisco Blogs
量子位
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
美团技术团队
D
Docker
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Tenable Blog

博客园 - chinese_submarine

QT项目性能调优小记 Windows下HG服务器的搭建 svn+tp-link+花生壳搭建外网服务器 udev介绍 极大极小博弈树的简洁(附Tic-Tac-Toe源码) 程序优化小记 Beating the Average------为什么要学习Lisp[转] 巧用qmake工具生成专业的makefile QT中拖拽的实现(附示例代码) 从QDataStream向QByteArray中写入数据时的注意点(QT) 如何保持GUI的响应流畅(QT平台) 也谈线程同步变量 windows7到期的问题 QT中的View Model模型系列一 从农夫养牛问题推广到斐波那契数列 TimeZoneChange事件的捕获 浏览器扩展系列————透明浏览器窗口的实现 浏览器扩展系列————异步可插入协议(pluggable protocol)的实现 浏览器扩展系列————给MSTHML添加内置脚本对象【包括自定义事件】
简述FPS的计算方法
chinese_submarine · 2010-02-04 · via 博客园 - chinese_submarine

FPSFrame per second的缩写,即每秒的帧数.这一术语广泛的应用于计算机图形学,视频采集,游戏等。

这里主要介绍一下视频游戏中的帧率,第一个First person shooter game的帧率只有大概6FPS,但是依然很成功。不过随着硬件设备,尤其是显卡性能的加强,现在游戏的帧率一般在30FPS~100FPS之间。由于每帧图像所消耗的时间不一样,造成帧率是在不断变化的,所以每个游戏都会设定一个最大的帧率,以保证平滑的切换。

下面就以一段QT中的代码介绍一下帧率的计算。

        // Timing...
        static QTime time;
        
static int frames = 0;
        
static bool started = false;if (!started || time.elapsed() > 1000) {
            qreal fps 
= frames * 1000/ time.elapsed();
            
if (fps == 0)
                m_current_fps 
= "counting fps...";
            
else
                m_current_fps 
= QString::fromLatin1("%3 FPS").arg((int) qRound(fps));

            time.start();
            started 

= true;
            frames 
= 0;

        } 

else {
            
++frames;

            p.setOpacity(

1);
            p.setFont(QFont(
"times"30));
            p.fillRect(
5, height() - 4025040, Qt::white);
            p.drawText(
10, height() - 8, m_current_fps);
        }
    }

由于一般实时的游戏都已一个定时器不断地刷新画面,所以每一帧的输出都是通过paintEvent来完成的。将上面这段代码放入paintEvent就可以统计出每秒的帧率。

那么怎么控制最大的帧率呢?

其实也很简单,就是通过设置定时器的interval来完成的,考虑到现在显示器的显示频率一般在60HZ,所以interval一般设置为1000/60ms 比较好,即60FPS是一个理论上最大的帧率。

posted on 2010-02-04 15:05  chinese_submarine  阅读(12123)  评论()    收藏  举报