|
本帖最后由 fosky 于 2011-4-1 11:52 编辑
- osgViewer::View *grViewQtWindow::init( int x, int y, int w, int h, const std::string& name/*=""*/, bool windowDecoration/*=false*/ )
- {
- osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
- osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
- traits->windowName = name;
- traits->windowDecoration = windowDecoration;
- traits->x = x;
- traits->y = y;
- traits->width = w;
- traits->height = h;
- traits->doubleBuffer = true;
- traits->alpha = ds->getMinimumNumAlphaBits();
- traits->stencil = ds->getMinimumNumStencilBits();
- traits->sampleBuffers = ds->getMultiSamples();
- traits->samples = ds->getNumMultiSamples();
-
- osgViewer::View* view = new osgViewer::View;
- osg::ref_ptr<osg::Camera> camera = view->getCamera();
- view->getCamera()->setGraphicsContext( new osgQt::GraphicsWindowQt(traits.get()) );
- view->getCamera()->setViewport( new osg::Viewport(x, y, w, h) );
- double fovy, z1, z2, aspectRatio;
- view->getCamera()->getProjectionMatrixAsPerspective(fovy,aspectRatio,z1,z2);
- view->getCamera()->setProjectionMatrixAsPerspective(fovy, static_cast<double>(w)/static_cast<double>(h), z1, z2);
-
- //view->setCamera( camera );
- osgQt::GraphicsWindowQt* gw = dynamic_cast<osgQt::GraphicsWindowQt*>( camera->getGraphicsContext() );
- m_gridLayout->addWidget( gw->getGraphWidget() );
- return view;
- }
复制代码 这是创建View的代码,可以正常显示一个背景,但是,在改变窗口大小后,就会出现
QGLContext::makeCurrent() : wglMakeCurrent failed: ???????????????С?
这个错误,此时还能正常显示.
这样改变大小几次后,窗口就会变黑,什么也看不到了.
然后出现一堆这样的文字:
Warning: detected OpenGL error 'invalid operation' after applying attribute Text
ure2D 02D047E8
Warning: detected OpenGL error 'invalid operation' at end of State::apply(StateS
et*)
Warning: detected OpenGL error 'invalid operation' at start of State::apply()
Warning: detected OpenGL error 'invalid operation' after applying GLMode 0xb44
Warning: detected OpenGL error 'invalid operation' after applying attribute Mate
rial 02C99D90
Warning: detected OpenGL error 'invalid operation' after applying GLMode 0xde1
Warning: detected OpenGL error 'invalid operation' after applying attribute Text
ure2D 02D04A98
Warning: detected OpenGL error 'invalid operation' at end of State::apply()
Warning: detected OpenGL error 'invalid operation' at after RenderBin::draw(..)
Warning: detected OpenGL error 'invalid operation' at start of State::apply()
Warning: detected OpenGL error 'invalid operation' after applying GLMode 0xb50
Warning: detected OpenGL error 'invalid operation' after applying GLMode 0xb71
Warning: detected OpenGL error 'invalid operation' after applying GLMode 0x4000
Warning: detected OpenGL error 'invalid operation' after applying attribute Mate
rial 02C64158
Warning: detected OpenGL error 'invalid operation' after applying attribute Ligh
tModel 02D0C6C0
Warning: detected OpenGL error 'invalid operation' after applying attribute Blen
dFunc 00DB0028
Warning: detected OpenGL error 'invalid operation' after applying attribute Colo
rMask 02CFD298
Warning: detected OpenGL error 'invalid operation' after applying attribute View
port 00DD60B0
Warning: detected OpenGL error 'invalid operation' after applying attribute TexE
nv 02D0C758
Warning: detected OpenGL error 'invalid operation' at end of State::apply()
Warning: detected OpenGL error 'invalid operation' at end of SceneView::draw()
希望知道这个错误的人,指点下迷津!!! |
|