Hi Xiaoshuxing,
You can't do OpenGL rendering in an event handle method, you have to
do the OpenGL rendering as part of the normal OSG drawing. You could
add extra OpenGL rendering by overriding the
SimpleViewer::frameDrawTraversal() or just implement it on the QT
side.
The other alternative is to simply add the stats HUD to main scene graph.
This week I'm working osgViewer, and will look at the issue of stats
and huds. SimpleViewer is just that a simple viewer, as part of
osgViewer there will be viewer classes with much more powerful and
flexibility, but with this will come a little more complexity. So
please watch this space :)
Robert.
On 12/19/06, xiaoshuxing <[EMAIL PROTECTED]> wrote:
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/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/