Hi, everyone
I found that simplerviewerQT4 can’t show the framerate like
osgProducer::viewer, so I wrote one myself, it’s basically a
GUIEventHandler.
But, it’s so weird that the text just don’t show out.
The calculation is finished, which I have traced down.
I have set a breakpoint in the drawimplementation of osgText::text, however,
it seems that this drawimplementation is not executed.
The source code of my eventhandler is as following:
bool MyEventHandler::handle(const osgGA::GUIEventAdapter &ea,
osgGA::GUIActionAdapter &aa)
{
if(!_firstFrame.valid())
{
_firstFrame = new osg::FrameStamp;
*_firstFrame = *(_sceneView->getFrameStamp());
_lastFrame = new osg::FrameStamp;
*_lastFrame = *_firstFrame;
}
if(true) // make the display or not an user interface later
{
if(ea.getEventType()==osgGA::GUIEventAdapter::FRAME)
{
char frText[128];
osg::ref_ptr<osg::FrameStamp> currentFrame = new
osg::FrameStamp;
*currentFrame = *(_sceneView->getFrameStamp());
if
(currentFrame->getFrameNumber()==_lastFrame->getFrameNumber())
{
return false;
}
double timePerFrame = currentFrame->getReferenceTime()
- _lastFrame->getReferenceTime();
sprintf(frText,"%4.2f",1.0/timePerFrame);
_frameRateCounterText->setText(frText);
_frameRateLabelText->drawImplementation(_sceneView->getRenderInfo());
_frameRateCounterText->drawImplementation(_sceneView->getRenderInfo());
//std::cout << 1.0/timePerFrame << std::endl;
_lastFrame = currentFrame;
}
}
return false;
}
And there’s another weird thing, I put my frame rate result to the console,
and I found that the highest framerate is only 40 fps even when I’m not
drawing anything.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/