Hi, Robert If it'll help to understand where problem might be - there are some details: I dont use any opengl functions directly, so i think osg management of opengl objects should be ok. Here some code i used to setup viewer on creation: On viewer init : graphicsWindow = new osgViewer::GraphicsWindowEmbedded(0,0,width(),height()); viewer->getCamera()->setViewport(new osg::Viewport(0,0,width(),height())); viewer->getCamera()->setGraphicsContext(graphicsWindow); viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
prior to destructing viewer i used next piece of code (which wasn't there initially, i added this when was trying to fight issue with model corruption, and it actually didnt make any difference): unsigned id = m_Ui.viewer->getCamera()->getGraphicsContext()->getState()->getContextID(); m_Ui.viewer->m_GraphicsWindow->makeCurrent(); osg::deleteAllGLObjects(id); osg::flushAllDeletedGLObjects(id); osg::discardAllGLObjects(id); osgDB::Registry::instance()->clearObjectCache(); osgDB::Registry::instance()->clearArchiveCache(); Scene recreated (without reusing old objects) each time new viewer created. 16.01.2012, 15:35, "Robert Osfield" <robert.osfi...@gmail.com>: > Hi Sergey, > > 2012/1/16 Sergey Polischuk <pol...@yandex.ru>: > >> I've destroyed complete scene with viewer and graphics context, and >> recreated it all with reading new models from files with disabled cache etc. >> On first run all was ok, and on next runs mesh would look all distorted >> (some vertices of mesh randomly displaced etc). Dont know if it problem with >> display lists or geometry data arrays in osg, but display lists should be >> brand new each time, because i've deleted all opengl objects before shutting >> down graphics context, and new context have different id, also object cache >> disabled, cleared and model reloaded each time from file, so there shouldn't >> be problem with osg data arrays. I have no idea what goes wrong. > > If you are bypassing much of osgViewer's context management then it's > possible to get the GL obejct caches that the OSG uses out of sync > with what you are doing. osgViewer does a range of operations to > clean up contexts and make sure the the GL object caches that the OSG > uses are flushed. If you are manually managing your own contexts then > you'll need to call releaseGLObjects() on your scene graph and call > osg::flushAllDeletedGLObjects(contextID) prior to closing the context, > if it this is outwith your control then calling > discardAllGLObjects(contextID) enables the discarding of all the GL > object caches. > > In the OSG the GL object caches are used to avoid problems with > deleting OpenGL objects in other threads than the graphics contexts > ones - as scene graphs can be deleted in any thread you need to cache, > the cache is also used to enable reuse of OpenGL objects like texture > objects and vbo's where possible, this is something that is very > useful for paging performance. > > Robert. > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org