Hi Robert,
My example code was only meant to show the symtoms of the problem I get it in 
my "real world" code. How can I use a composite viewer to implement views 
within multiple browser plugin instances, potentially on different web pages? 
Would I have to make the composite viewer a singleton that holds references to 
the embedded windows created for each plugin instance? It's never gonna fly! 

Interesting update to the problem though; it seems not related to the embedding 
of the textures within the IVE, but more to do with the way IVE reader creates 
images. The reason being that if I convert cow.osg using "osgconv -O 
noTexturesInIVEFile cow.osg cow.ive" I still get the problem, but if I load 
"cow.osg" into my example, it seems fine.

Chris Denham.



robertosfield wrote:
> 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 <> 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
> > 
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > 
> _______________________________________________
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  ------------------
> Post generated by Mail2Forum


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=44813#44813





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to