|
根据osgviewerMFC,我在
void OsgImporter::InitCamaConfig()
{
CRect rect;
::GetWindowRect(m_hWnd,rect);
viewer=new osgViewer::Viewer();
viewer->addEventHandler(new osgViewer::StatsHandler);
osg::ref_ptr<osg::GraphicsContext::Traits> traits=new osg::GraphicsContext::Traits;
osg::ref_ptr<osg::Referenced> windata=new osgViewer::GraphicsWindowWin32::WindowData(m_hWnd);
traits->x=0;
traits->y=0;
traits->width=rect.right-rect.left;
traits->height=rect.bottom-rect.top;
traits->windowDecoration=false;
traits->doubleBuffer=true;
traits->sharedContext=0;
traits->setInheritedWindowPixelFormat=true;
traits->inheritedWindowData=windata;
osg::GraphicsContext* gc=osg::GraphicsContext::createGraphicsContext(traits.get());
osg::ref_ptr<osg::Camera> camara=new osg::Camera();
camara->setGraphicsContext(gc);
camara->setViewport(new osg::Viewport(traits->x,traits->y,traits->width,traits->height));
viewer->addSlave(camara.get());
viewer->setCameraManipulator(keyswitch);
viewer->setSceneData(root.get());
viewer->addEventHandler(new UseEventHandler); //!!!!!!!!!!!!
viewer->realize();
double fovy,aspectRatio,z1,z2;
viewer->getCamera()->getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
aspectRatio=double(traits->width)/double(traits->height);
viewer->getCamera()->setProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
}
之中在
viewer->setSceneData(root.get());
下加的一个事件回调
viewer->addEventHandler(new UseEventHandler);
出了问题
编译连接都能通过,之后程序就停止响应了
调试后出现file:///C:/Users/%E5%88%98%E5%AE%9D/Desktop/%E6%8D%95%E8%8E%B7.PNG内存冲突以及以下提示
> osg55-osgGA.dll!67ca19bb()
[下面的框架可能不正确和/或缺失,没有为 osg55-osgGA.dll 加载符号]
osg55-osgViewer.dll!66c5efab()
kernel32.dll!77a3f1cc()
msvcr90.dll!6ccf38da()
msvcr90.dll!6ccb332b()
kernel32.dll!77a41194()
ntdll.dll!77dcb3f5()
ntdll.dll!77dcb3c8() |
|