目前的流程是
osgViewer::viewBase:: frame()
{
viewerInit();[
//创建帧事件,并将漫游器与事件和视口相关联
-> osgViewer::Viewer::ViewerInit()
-> osgViewer::View::Init();
->(1)osgGA::EventQueue::createEvent();
(2)osgGA::MatrixManipulator::Init();
->(2.1)各种漫游器::init()
]
isRealized();[
//获取图形上下文数组。再遍历上下文数组,只要有一个准备好就Ok
-> osgViewer::Viewer::isRealized();
->(1)osgViewer::Viewer::getContexts().
->(1.1)osg::camera::getGraphicsContext()
->(1.2)osg::View::getNumSlaves()
->(1.3)osg::View::getSlave()
->(1.4)LessGraphicsContext()->osg::GraphicContext::getTraits()
->(2)osg::GraphicContext::isRealized()
]
realize();
advance(simulationTime);
eventTraversal();
updateTraversal();
renderingTraversals();
}
接下来,就是osg::GraphicContext::isRealized(),顾名思义,就是图形上下文是否准备好了.。
看看代码
bool Viewer::isRealized () const
{
Contexts contexts;
const_cast<Viewer*>(this)->getContexts(contexts);
unsigned int numRealizedWindows = 0;
// clear out all the previously assigned operations
for(Contexts::iterator citr = contexts.begin();
citr != contexts.end();
++citr)
{
if ((*citr)->isRealized()) ++numRealizedWindows;
}
return numRealizedWindows > 0;
}
得到图形上下文数组,并遍历各个是否准备并可用
osg::GraphicsContext::isRealized()
/** Return true if the graphics context has been realized and is ready to use.*/
inline bool isRealized() const { return isRealizedImplementation(); }
下面看看
isRealizedImplementation()
发现是个纯虚函数
/** Return true if the graphics context has been realized, and is ready to use, implementation.
* Pure virtual - must be implemented by concrete implementations of GraphicsContext. */
virtual bool isRealizedImplementation() const = 0;
有两个派生类
osgViewer::GraphicsWindow
osgViewer::PixelBufferWin32
先看osgViewer::GraphicsWindow::isRealizedImplementation()
/** Return true if the graphics context has been realized, and is ready to use, implementation.
* Pure virtual - must be implemented by concrete implementations of GraphicsContext. */
virtual bool isRealizedImplementation() const { osg::notify(osg::NOTICE)<<"GraphicsWindow::isRealizedImplementation() not implemented."<<std::endl; return false; }
基本上相当于没写啥,还得看派生类
osgViewer::GraphicsWindow的派生类有
class GraphicsWindowEmbedded : public GraphicsWindow
class GraphicsWindowWin32 : public osgViewer::GraphicsWindow
先看GraphicsWindowEmbedded::isRealizedImplementation()
virtual bool isRealizedImplementation() const { return true; }
再看
GraphicsWindowWin32 : :isRealizedImplementation()
virtual bool isRealizedImplementation() const { return _realized; }
说明GraphicsWindowWin32干了点实事
再看osgViewer::PixelBufferWin32::isRealizedImplementation()
virtual bool isRealizedImplementation() const { return _realized; }
也干了实事,
这个倒是比较简单,
总结下流程
osgViewer::viewBase:: frame()
{
viewerInit();[
//创建帧事件,并将漫游器与事件和视口相关联
-> osgViewer::Viewer::ViewerInit()
-> osgViewer::View::Init();
->(1)osgGA::EventQueue::createEvent();
(2)osgGA::MatrixManipulator::Init();
->(2.1)各种漫游器::init()
]
isRealized();[
//获取图形上下文数组。再遍历上下文数组,只要有一个准备好就Ok
-> osgViewer::Viewer::isRealized();
->(1)osgViewer::Viewer::getContexts().
->(1.1)osg::camera::getGraphicsContext()
->(1.2)osg::View::getNumSlaves()
->(1.3)osg::View::getSlave()
->(1.4)LessGraphicsContext()->osg::GraphicContext::getTraits()
->(2)osg::GraphicContext::isRealized()
->(2.1)->(1)
->(2.2)osg::GraphicsContext::isRealized()
->osg::GraphicsContext::isRealizedImplementation()
->(2.2.1)osgViewer::GraphicsWindow::isRealizedImplementation()
->(2.2.1.1)osgViewer:: GraphicsWindowWin32 ::isRealizedImplementation()
->(2.2.1.2) osgViewer::GraphicsWindowEmbedded ::isRealizedImplementation()
->(2.2.2)osgViewer::PixelBufferWin32::isRealizedImplementation()
-
]
realize();
advance(simulationTime);
eventTraversal();
updateTraversal();
renderingTraversals();
}