|
GestWidget::GestWidget(QWidget * parent, const char * name, const QGLWidget * shareWidget, WindowFlags f)
: QGLWidget(parent)
{
QGLWidget(parent, shareWidget, f);
_gw = new osgViewer::GraphicsWindowEmbedded(0,0,width(),height());
setFocusPolicy(Qt::ClickFocus);
//getCamera()->setViewport(new osg::Viewport(0,0,width(),height()));
getCamera()->setViewport(0,0,width(),height());
getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(width())/static_cast<double>(height()), 1.0f, 10000.0f);
getCamera()->setGraphicsContext(getGraphicsWindow());
//setThreadingModel(osgViewer::Viewer::SingleThreaded);
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateGL()));//Set frequency for 20Hz
_timer.start(50);
modelRoot = NULL;
}
以上为源码, osg嵌入到qt工程的构造函数,编译链接都通过, 运行出现错误
HandCaga.exe 中的 0x59727c00 (osg65-osgd.dll) 处有未经处理的异常: 0xC0000005: 写入位置 0x00000000 时发生访问冲突
单步调试至getCamera()->setGraphicContext(getGraphicsWindow());语句结束时出现, getGraphicWindow()函数运行没问题(不是空); 为什么会出现这种问题? |
|