Hi Aurelien,

On 14 February 2012 22:01, Aurelien Albert <[email protected]> wrote:
> Is it the same mechanism for StateAttribute ?

Yes.

> For example, if I create a subclass "MyTexture" of osg::Texture, will 
> compileGLObjects/releaseGLObjects methods of "MyTexture" be automatically 
> called when needed ?

Yes, and again the MyTexture::apply() method shouldn't assume that
compielGLObjects() will be called prior to the first call to apply().

> Does that mean I should call "releaseGLObjects" every time I remove a 
> subgraph from the main viewer graph ?

It depends if you keep that subgraph around longer than the lifetime
of the graphics windows associated with the viewer, if you do then
you'll need to call releaseGLObjects when the windows are closed.  If
you destroy the subgraph then it will automatically release all the GL
objects associated with it as the destructors of OpenGL related OSG
classes should do their own house keeping.  Note that when doing a
release of the GL objects these classes can't directly call OpenGL to
get rid of the resources, but have to place them in a per context
buffer that keeps the GL handles around to be deleted from the
appropriate graphics thread - this has to be done as you can delete
OSG objects from any thread.

> Is it enough to call it on the subgraph top object or should I call it 
> recursively ?

releaseGLObjects() is designed to be called from the top of the
sugbgraph, it will handle the traversal down the subgraph calling the
respective relaaseGLObjects calls.

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

Reply via email to