Hi Robert,
The StatsHandler is actually not able to show the time consumed for
prerender-cameras. This submission contains an extension for StatsHandler,
which makes it possible to show statistics about prerender-cameras (and other
cameras).
The following changes are made by this patch:
1.) a new virtual method getStatCameras() is introduced in StatsHandler.cpp
(and declared in ViewerEventHandlers). It makes it possible in an inherited
StatsHandler-class to add prerender-cameras.
2.) Because prerender-cameras are not assigned to a view, the method
updateSceneView() in Renderer.cpp is extended to get the starttick from
EventQueue
Here an example, how to show statistics of a prerender-cam:
Code:
class MyStatsHandler : public osgViewer::StatsHandler
{
public:
MyStatsHandler() {};
virtual ~MyStatsHandler() {};
virtual void getStatCameras(osgViewer::ViewerBase::Cameras& cameras,
osgViewer::ViewerBase* viewer);
static void addCamera(osg::Camera* camera);
static void removeCamera(osg::Camera* camera);
typedef std::vector<osg::Camera*> CamerasType;
static CamerasType _prerenderCameras;
}
void CoDisiStatsHandler::addCamera(osg::Camera* camera)
{
_prerenderCameras.push_back(camera);
}
void MyStatsHandler::removeCamera(osg::Camera* camera)
{
for(CamerasType::iterator itr = _prerenderCameras.begin();
itr != _prerenderCameras.end();
++itr)
{
if ((*itr) == camera)
{
_prerenderCameras.erase(itr);
break;
}
}
}
void MyStatsHandler::getStatCameras(osgViewer::ViewerBase::Cameras& cameras,
osgViewer::ViewerBase* viewer)
{
viewer->getCameras(cameras);
for(CamerasType::iterator itr = _prerenderCameras.begin();
itr != _prerenderCameras.end();
++itr)
{
cameras.push_back(*itr);
}
}
The code is based on OSG-3.4.0
Thank you for merging this!
Prost,
WeSee
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=65810#65810
Attachments:
http://forum.openscenegraph.org//files/stathandler_extension_669.zip
_______________________________________________
osg-submissions mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-submissions-openscenegraph.org