Texture disappears when more than two earth are created using CompositeViewer

classic Classic list List threaded Threaded
1 message Options
jikaizhang jikaizhang
Reply | Threaded
Open this post in threaded view
|

Texture disappears when more than two earth are created using CompositeViewer

Hi,
I use CompositeViewer to build multiple earth views on QT platform. When the main window displays other scenes at the beginning and commands to create multiple earth views, everything is normal. But if the main window displays the earth scenes at the beginning and creates additional earth scenes, the second earth will lose its texture.In addition, it will also prompt  Warning: detected OpenGL error 'invalid enumerant' at After Renderer::compile  errors. I have seen in previous posts that setUnrefImageDataAfterApplyPolicy(true, false); can be used to solve this problem, but I still have no effect after adding this statement.The osgEarth version I use is 2.8,The code for adding view is as follows:

QWidget* addViewWidget( osgQt::GraphicsWindowQt* gw, osg::ref_ptr<osg::Node> scene )
{
        osgViewer::View* view = new osgViewer::View;
        view->getDatabasePager()->setUnrefImageDataAfterApplyPolicy(true, false);
        stopThreading();
        addView( view );
        startThreading();
       
        osg::Camera* camera = view->getCamera();
       
        camera->setGraphicsContext( gw );

        const osg::GraphicsContext::Traits* traits = gw->getTraits();

        camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
        camera->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
        camera->setProjectionMatrixAsPerspective(30.0f, static_cast<double>(traits->width)/static_cast<double>(traits->height), 1.0f, 10000.0f );
       
       
        view->setSceneData( scene );
        view->addEventHandler( new osgViewer::StatsHandler );
        view->setCameraManipulator( new osgGA::MultiTouchTrackballManipulator );
       
        //view->addEventHandler(new osgViewer::WindowSizeHandler);
        gw->setTouchEventsEnabled( true );
        return gw->getGLWidget();
}

Only one earth is right:


More than two problems occur: