Thanks for the suggestions Robert. I played around with rebuilding my OpenGL objects some more and found that the necessary steps are:
sceneview->releaseAllGLObjects(); state->setContextID(state->getContextID() + 1); For completness's sake, I've been doing this scenegraphroot->releaseGLObjects(); sceneview->releaseAllGLObjects(); sceneview->flushAllDeletedGLObjects(); state->setContextID(state->getContextID() + 1); However, the extra two steps don't appear to be necessary. If I only increment the context ID and do nothing else, most OpenGL objects get rebuilt except for the ones that were onscreen at the time of the context switch. This makes it look as if all objects not culled on the last frame do not get re-initialized. So while I have a working solution, it might be fragile since I still don't completely understand what's going on inside OSG. I'd like to hear any other thoughts you or anyone else have on this problem. -- Terry Welsh / mogumbo 'at' gmail.com www.reallyslick.com / www.mogumbo.com > > Message: 11 > Date: Mon, 19 Oct 2009 09:01:21 +0100 > From: Robert Osfield <[email protected]> > To: OpenSceneGraph Users <[email protected]> > Subject: Re: [osg-users] re-initialize OpenGL objects after window > resize > Message-ID: > <[email protected]> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi Terry, > > On Sun, Oct 18, 2009 at 11:12 PM, Terry Welsh <[email protected]> wrote: >> I'm working on and OSG/SDL application. ?Resizing the window in Linux >> works fine, but resizing it in Windows causes the app to lose all its >> OpenGL objects. ?Is there a recommended way to re-initialize all >> OpenGL objects? > > I really wouldn't recommend using SDL for windowing... > > In your case it does sound like SDL is deleting the original graphics > context and then recreating a completely new one on resize. > >> So far I have been experimenting with SceneView's releaseAllGLObjects, >> flushAllDeletedGLObjects, and COMPILE_GLOBJECTS_AT_INIT. ?But this has >> mostly led to crashes and hasn't fixed the problem. ?Just thought I >> would take a break and see if anyone has any other suggestions.... > > The problem is that the scene graph itself is retaining handles to the > original OpenGL objects and still has this around when you try to > reapply them to a completely new graphics context, which > unsurprisingly causes problems. The scene graph itself doesn't know > about the fact that you've changed the graphics context from > underneath it so you'll need to tell it but doing a > scenegraph->releaseGLObjects(); The SceneView methods just clean up > already released GL objects, so you'd call these after the scenegraph > release. > > Robert. > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

