Added the threading model to stats

This commit is contained in:
Robert Osfield 2007-02-08 12:47:35 +00:00
parent 12dfddea68
commit 19608966d0
2 changed files with 52 additions and 10 deletions

View File

@ -58,19 +58,24 @@ class OSGVIEWER_EXPORT StatsHandler : public osgGA::GUIEventHandler
osg::Node* createCameraStats(const std::string& font, osg::Vec3& pos, float startBlocks, bool aquireGPUStats, float characterSize, osg::Stats* viewerStats, osg::Camera* camera);
void setUpScene(osgViewer::Viewer* viewer);
void updateThreadingModelText();
int _keyEventTogglesOnScreenStats;
int _keyEventPrintsOutStats;
int _keyEventTogglesOnScreenStats;
int _keyEventPrintsOutStats;
int _statsType;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::Switch> _switch;
int _statsType;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::Switch> _switch;
osgViewer::Viewer::ThreadingModel _threadingModel;
osg::ref_ptr<osgText::Text> _threadingModelText;
unsigned int _frameRateChildNum;
unsigned int _viewerChildNum;
unsigned int _sceneChildNum;
unsigned int _numBlocks;
double _blockMultiplier;
unsigned int _frameRateChildNum;
unsigned int _viewerChildNum;
unsigned int _sceneChildNum;
unsigned int _numBlocks;
double _blockMultiplier;
};

View File

@ -22,6 +22,7 @@ StatsHandler::StatsHandler():
_keyEventTogglesOnScreenStats('s'),
_keyEventPrintsOutStats('S'),
_statsType(NO_STATS),
_threadingModel(osgViewer::Viewer::SingleThreaded),
_frameRateChildNum(0),
_viewerChildNum(0),
_sceneChildNum(0),
@ -34,6 +35,12 @@ bool StatsHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdap
{
osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
if (!viewer) return false;
if (_threadingModelText.valid() && viewer->getThreadingModel()!=_threadingModel)
{
_threadingModel = viewer->getThreadingModel();
updateThreadingModelText();
}
switch(ea.getEventType())
{
@ -165,6 +172,18 @@ bool StatsHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdap
}
void StatsHandler::updateThreadingModelText()
{
switch(_threadingModel)
{
case(osgViewer::Viewer::SingleThreaded): _threadingModelText->setText("ThreadingModel: SingleThreaded"); break;
case(osgViewer::Viewer::CullDrawThreadPerContext): _threadingModelText->setText("ThreadingModel: CullDrawThreadPerContext"); break;
case(osgViewer::Viewer::DrawThreadPerContext): _threadingModelText->setText("ThreadingModel: DrawThreadPerContext"); break;
case(osgViewer::Viewer::CullThreadPerCameraDrawThreadPerContext): _threadingModelText->setText("ThreadingModel: CullThreadPerCameraDrawThreadPerContext"); break;
case(osgViewer::Viewer::AutomaticSelection): _threadingModelText->setText("ThreadingModel: AutomaticSelection"); break;
}
}
void StatsHandler::setUpHUDCamera(osgViewer::Viewer* viewer)
{
osgViewer::Viewer::Windows windows;
@ -519,6 +538,24 @@ void StatsHandler::setUpScene(osgViewer::Viewer* viewer)
osg::Geode* geode = new osg::Geode();
group->addChild(geode);
{
pos.x() = leftPos;
_threadingModelText = new osgText::Text;
geode->addDrawable( _threadingModelText.get() );
_threadingModelText->setColor(colorFR);
_threadingModelText->setFont(font);
_threadingModelText->setCharacterSize(characterSize);
_threadingModelText->setPosition(pos);
updateThreadingModelText();
pos.y() -= characterSize*1.5f;
}
float topOfViewerStats = pos.y() + characterSize;
{