From 337f24051bc06829ba240b4cb38580f5fae20e7e Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 31 Dec 2018 11:06:45 +0000 Subject: [PATCH] Changed the clean up of the GL objects on destruction so that the destructors of the arrays/primitives themselves do the release rather than have it done explictly in the destructor. This allows arrays/primitives to be shared. --- src/osg/Geometry.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index 69fb840cf..fe6f65bb6 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -83,7 +83,21 @@ Geometry::Geometry(const Geometry& geometry,const CopyOp& copyop): Geometry::~Geometry() { _stateset = 0; + +#if 1 + // use the destructors to automatically handle GL object clean up when the array/primtives ref count goes to 0 + _primitives.clear(); + _vertexArray = 0; + _normalArray = 0; + _colorArray = 0; + _secondaryColorArray = 0; + _fogCoordArray = 0; + _texCoordList.clear(); + _vertexAttribList.clear(); +#else + // original clean up that cleans up GL objects regardless of any sharing of arrays/primitives Geometry::releaseGLObjects(); +#endif } #define ARRAY_NOT_EMPTY(array) (array!=0 && array->getNumElements()!=0)