Hi Andy,

Sharing contexts should be able to get around some of the issues of
resizing cause contexts to be recreated, although this depends very
much on the window API your using.

W.r.t cleaning all contexts, your can use node->relaseGLObjects()
without passing in State*  and it'll release all the GL obejcts for
all contexts.  Now this dumps the GL Object ID's in the respective
deleted OpenGL object caches that the OSG maintains, these you then
need to flush from the appropriate graphics context, or... if you are
using the latest OSG SVN you can use the new discard functionality,
that just throws away the cached OpenGL ID's without calling OpenGL at
all, so its doesn't require the context to be current, or even still
alive.

The new functions for doing flush and discard can be found in
include/osg/GLObjects:

/** Flush all deleted OpenGL objects within the specified availableTime.
  * Note, must be called from a thread which has current the graphics
context associated with contextID. */
extern OSG_EXPORT void flushDeletedGLObjects(unsigned int contextID,
double currentTime, double& availableTime);

/** Flush all deleted OpenGL objects.
  * Note, must be called from a thread which has current the graphics
context associated with contextID. */
extern OSG_EXPORT void flushAllDeletedGLObjects(unsigned int contextID);

/** Discard all deleted OpenGL objects.
  * Note, unlike flushAllDeletedObjectObjects discard does not
  * do any OpenGL calls so can be called from any thread, but as a
consequence it
  * also doesn't remove the associated OpenGL resource so discard
should only be
  * called when the associated graphics context is being/has been closed. */
extern OSG_EXPORT void discardAllDeletedGLObjects(unsigned int contextID);


I presume this is exactly what you're looking for :-)

Robert.


On Jan 9, 2008 2:58 PM, Andy Skinner <[EMAIL PROTECTED]> wrote:
> We are using the OSG along with JOGL to provide and manage contexts.  In
> general, this has worked well, and we have seen others reporting the
> same thing on this mailing list.  (We're not yet using the embedded
> graphics window, however, but have our own SceneView, etc.)
>
> One thing that we had to be careful to do was manage context IDs
> correctly.  We use multiple windows, and windows can be removed and
> return, so that their contexts can be removed and remade.  We discovered
> that if we were removing a window and creating it again, we could use
> JOGL and some fancy footwork to tell the OSG to clean up a context
> (releaseAllGLObjects() and flushAllDeletedGLObjects()) and stop drawing
> in it until the context is initialized again.  We seem to be doing
> alright with that, since it seems we're getting notified about the
> context going away (removeNotify() in Java).
>
> However, in some cases, as with the JOGL lightweight canvas, which uses
> a PBuffer, a context can be recreated when the object is resized.  We
> don't seem to be getting any messages in time to clean up OSG's OpenGL
> objects while the context is current.
>
> Is there a way, or would it make sense, to allow us to clean up all of
> the OpenGL objects associated with a context, without that context being
> current?  I don't know what happens to OpenGL objects when their context
> goes away, and I'm wondering whether, in this case, we can tell OSG to
> clean up its stuff but it doesn't need to tell OpenGL anything.
>
> thanks,
> andy
>
> _______________________________________________
> 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

Reply via email to