HI Joakim, You can only compile OpenGL objects form the thread with the context current. The easist way to do this would be to just use the existing osgViewer::Renderer::setCompileOnNextDraw(true) functionality on all your active cameras. You can get the renderer by doing:
osgViewer::Viewer::Renderer* rendering = dynamic_cast<osgViewer::Renderer*>(camera->getRenderer()); The cameras can be got using the viewer.getCameras(cameras) method in the same way as you've done for getContexts(). Robert. On Mon, Feb 23, 2009 at 4:31 PM, Joakim Simonsson <joa...@autosim.no> wrote: > > Hi, > > I use 4 screens (running on two nvidia cards). > > When I don't precompile the gl objects things look as expected. But when I > precompile stuff, things are shown only on some graphic contexts. > > 1. I am loading models on my own background thread. > > 2. This is what I do on the "main" thread, before the update traversal: > > osgUtil::GLObjectsVisitor glov; > glov.setNodeMaskOverride(0xffffffff); > > osgViewer::Viewer::Contexts graphicContexts; > myViewer->getContexts(graphicContexts); > > for (osgViewer::Viewer::Contexts::iterator it = graphicContexts.begin(); > it != graphicContexts.end(); > ++it) > { > glov.setState((*it)->getState()); > glov.apply(*loadedNode); > } > > Finally I add "loadedNode" to the scenegraph. > > > Is this the wrong approach? > > -- > Joakim Simonsson > _______________________________________________ > 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