如何显示正确帧频?
我想测试我的场景绘制的帧频,使用:viewer->addEventHandler(new osgViewer::StatsHandler);后发现帧频显示固定为40fps左右,
我换一个模型也是大约40.fps左右,将物体移开到视景体外也是40.0fps左右,不知为什么?
应该是osg对帧做了处理,那么如何实时显示当前实际的未限定的帧频呢? 用osg::Timer类自己计算下呢 自己写 viewer->run(),通过viewer->frame() 设置时间 进行计算。 osg::Timer* timer= new osg::Timer;
osg::Timer_t start_T=0,start_T2=0, end_T=0,end_T2=0;
int count = 0;
while (!viewer->done())
{
if (count == 0)
{
start_T2 = timer->tick();
}
start_T = timer->tick();
viewer->frame();
end_T = timer->tick();
std::cout << "即时帧率为: " << 1 / timer->delta_s(start_T, end_T) << std::endl;
count++;
if (count == 5)
{
end_T2 = timer->tick();
std::cout << "平均帧率为: " << 5 / timer->delta_s(start_T2, end_T2) << std::endl;
count = 0;
}
}
页:
[1]