[osg-users] Removing objects with shared GL state from scene graph
Robert Osfield
robert.osfield at gmail.com
Sun Jul 7 04:59:41 PDT 2019
Hi Chris,
I'll have a look at the leads you've detailed on my return next week,
Cheers,
Robert.
On Thu, 4 Jul 2019 at 10:42, Chris Djali <krizdjali at gmail.com> wrote:
> Hi,
>
> Turns out that it's not a font in the object cache that's causing me grief
> after all, but instead the static default font here:
> https://github.com/openscenegraph/OpenSceneGraph/blob/OpenSceneGraph-3.6/src/osgText/Font.cpp#L40.
> This is initialised from a GLubyte array instead of a file, so never ends
> up in the object cache.
>
> I can manually call releaseGLObjects on it when a graphics context is
> destroyed, which solves the problem for my application, but I can provide
> an example of an OSG application that CodeXL says leaks stuff to prove that
> there's still a footgun.
>
>
> Code:
> int main()
> {
> osgViewer::Viewer viewer;
>
> // Use an auto transform so the text actually faces the screen
> osg::ref_ptr<osg::AutoTransform> scene = new osg::AutoTransform();
> scene->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
> viewer.setSceneData(scene);
>
> osg::ref_ptr<osgText::Text> text1 = new osgText::Text();
> text1->setText("text1");
> scene->addChild(text1);
>
> // Display one or more frames
> viewer.setCameraManipulator(new osgGA::TrackballManipulator());
> for (int i = 0; i < 100; ++i)
> viewer.frame();
>
> // Remove a text node
> scene->removeChild(text1);
>
> // Pick which path depending on whether or not we trust all references
> to things to go away
> if (false)
> {
> text1->releaseGLObjects();
> }
> else
> {
>
> }
>
> text1 = nullptr;
>
> // osgText::Font::getDefaultFont::s_defaultFont still exists, so the
> default font isn't released
>
> return viewer.run();
> }
>
>
>
> As before, CodeXL is still reporting the following error:
>
> [Image:
> https://cdn.discordapp.com/attachments/502999428798480387/596112745104146487/unknown.png
> ]
>
> Maybe it would be a good idea for static OSG objects to all be held
> together in a global vector somewhere so that their GL objects can be
> released whenever a context is destroyed. Maybe something like that exists
> already and the default font just got forgotten.
>
> Cheers,
> Chris
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=76365#76365
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190707/de2c643a/attachment.html>
More information about the osg-users
mailing list