HI Aurelien,

On 14 February 2012 11:09, Aurelien Albert <[email protected]> wrote:
> I found a workaround :
>
> 1/ In MyGeometry::drawImplementation :
> => check if objects are compiled for this context, if not, call 
> "compileGLObjects"

compileGLObjects() is only called during the compile traversals done
after viewer realizes it's windows or by the DatabasePager when it's
loading a new subgraph.  If you just add your data to the scene graph
the OSG won't automatically call compileGLobjects() and you code
shouldn't assume that this will be needed.

One things to take into account is that osg::Drawable::draw(..) inline
method provides support for display lists automatically for you if
these are enabled (they are by default) and if display lists are
required will be created automatically for you regardless of whether a
compile traversal has occurred or not - it's all done on demand in the
draw traversal.

If you have a look at the VBO support in osg::Geometry you'll see that
it doesn't require an explict call to compileGLObjects() and will
setup the VBO and EBO's automatically on demand if required.

> 2/ In MyGeometry::~MyGeometry :
> => call releaseGLObjects(NULL)
>
> But I'm surprised that I have to do this "by hands".. did I miss something ?

You should need to do this by hand, the releaseGLObjects() should be
called on clean up of graphics contexts that are closed prior to
deletion of the subgraphs.  If you subgraphs aren't attached to the
viewer's scene graph it won't be able to call your detached subgraphs
though, so in these instances you'll need to call the methods
explicitly.

Another thing to watch is it's easy to get the method type wrong when
overloading so you end up creating a new method rather than
overloading an existing one.

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

Reply via email to