Hi Chris, Using two independent viewers in an application is not normal or recommended. I would recommend that you use a single CompositeViewer with two Views. See the osgcompositeviewer example.
Robert. On 13 January 2012 14:18, Chris Denham <[email protected]> wrote: > I'm having some problems connected with the use of textures embedded within > IVE files. The problem arises when I use the same IVE model instance from > within two instances of osgViewer::Viewer which results in unpredictable > rendering of textures in one of the viewer instances, usually the texture > goes white when I delete one viewer instance. If the embedded textures were > also compressed, then I also get some GL errors, typically: > > "Warning: detected OpenGL error 'invalid enumerant' at after > RenderBin::draw(..)" > > To be honest, I'm not surprised that this sharing of scene graph data between > osg Viewer instances causes a problem. In fact, I’m surprised that more > things don’t break. However, the reason this scenario crops up is that my > osg viewer is running inside a web based plugin, and hence I get an osg > viewer instance within each instance of the plugin that the web browser > creates. You might now be wondering why the browser plugin instances share > any scene graph data, and in fact I was a bit surprised that they were. I > didn’t want them to share data! It turns out that the reason the browser > plugin instances share data is because of the cache provided by the osg > Registry singleton. It would have been nice if each browser plugin instance > ended up with their own osg Registry singleton, but they don’t! > (I don’t really want to get on my hobby horse about all the pains that the > singleton pattern can cause, but this is certainly one to add to my list) > > So, my questions boil down to : > If viewer instance 1 caches “cow.ive” in Registry singleton, how do I prevent > viewer instance 2 from using it? > If it does use the cached version, why does cause a problem (seemingly only > with textures that were embedded in IVE)? > Is there a way to “tweak” the IVE embedded textures so they can be shared > successfully in this scenario? > > I have reduced the problem down to a simple example (20 lines or so) that > exhibits the same symptoms: > > > Code: > static osg::ref_ptr<osg::Node> model = NULL; > > class ViewerThread : public OpenThreads::Thread > { > public: > ViewerThread(int x, int y) : x(x), y(y) { } > void run() > { > osgViewer::Viewer viewer; > viewer.setUpViewInWindow(x, y, 400, 300); > viewer.setSceneData(model); > viewer.run(); > } > int x, y; > }; > > int main(int argc, char* argv[]) > { > model = osgDB::readNodeFile("cow.ive"); > > ViewerThread* thread1 = new ViewerThread(100, 100); > thread1->start(); > > ViewerThread* thread2 = new ViewerThread(500, 100); > thread2->start(); > > while(true); > > return 0; > } > > > > Chris Denham > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=44810#44810 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

