Add default font releaseGLObjects workaround for OSG <3.65

This resolves https://gitlab.com/OpenMW/openmw/issues/4704

I've not compiled this or anything and I'm going off my memory from
around ten or eleven months ago, so if this fails CI or causes more
problems, that's why. The most likely issue is that we'll need to make
the context current before releasing the program.
pull/558/head
AnyOldName3 5 years ago
parent 2652b10b9c
commit 73722eedf3

@ -100,6 +100,14 @@ RenderWidget::~RenderWidget()
try
{
CompositeViewer::get().removeView(mView);
#if OSG_VERSION_LESS_THAN(3,6,5)
// before OSG 3.6.4, the default font was a static object, and if it wasn't attached to the scene when a graphics context was destroyed, it's program wouldn't be released.
// 3.6.4 moved it into the object cache, which meant it usually got released, but not here.
// 3.6.5 improved cleanup with osgViewer::CompositeViewer::removeView so it more reliably released associated state for objects in the object cache.
osg::ref_ptr<osg::GraphicsContext> graphicsContext = mView->getCamera()->getGraphicsContext();
osgText::Font::getDefaultFont()->releaseGLObjects(graphicsContext->getState());
#endif
}
catch(const std::exception& e)
{

Loading…
Cancel
Save