Restructured the clean up of arrays/primitives and GL objects
This commit is contained in:
parent
b7947b13f3
commit
fd47b84bd7
@ -256,8 +256,28 @@ Drawable::Drawable(const Drawable& drawable,const CopyOp& copyop):
|
||||
|
||||
Drawable::~Drawable()
|
||||
{
|
||||
_stateset = 0;
|
||||
Drawable::releaseGLObjects();
|
||||
// clean up display lists if assigned, for the display lists size we can't use glGLObjectSizeHint() as it's a virtual function, so have to default to a 0 size hint.
|
||||
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
|
||||
for(unsigned int i=0;i<_globjList.size();++i)
|
||||
{
|
||||
if (_globjList[i] != 0)
|
||||
{
|
||||
Drawable::deleteDisplayList(i,_globjList[i], 0); // we don't know getGLObjectSizeHint()
|
||||
_globjList[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// clean up VertexArrayState
|
||||
for(unsigned int i=0; i<_vertexArrayStateList.size(); ++i)
|
||||
{
|
||||
VertexArrayState* vas = _vertexArrayStateList[i].get();
|
||||
if (vas)
|
||||
{
|
||||
vas->release();
|
||||
_vertexArrayStateList[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
osg::MatrixList Drawable::getWorldMatrices(const osg::Node* haltTraversalAtNode) const
|
||||
@ -319,6 +339,7 @@ void Drawable::releaseGLObjects(State* state) const
|
||||
// current OpenGL context.
|
||||
unsigned int contextID = state->getContextID();
|
||||
|
||||
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
|
||||
if (_useDisplayList)
|
||||
{
|
||||
// get the globj for the current contextID.
|
||||
@ -331,6 +352,7 @@ void Drawable::releaseGLObjects(State* state) const
|
||||
globj = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
VertexArrayState* vas = contextID <_vertexArrayStateList.size() ? _vertexArrayStateList[contextID].get() : 0;
|
||||
if (vas)
|
||||
|
@ -82,21 +82,16 @@ 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();
|
||||
// clean up display lists if assigned, and use the GLObjectSizeHint() while prior to it being invalidated by the automatic clean up of arrays that will invalidate the getGLObjectSizeHint() value.
|
||||
#ifdef OSG_GL_DISPLAYLISTS_AVAILABLE
|
||||
for(unsigned int i=0;i<_globjList.size();++i)
|
||||
{
|
||||
if (_globjList[i] != 0)
|
||||
{
|
||||
Drawable::deleteDisplayList(i,_globjList[i], getGLObjectSizeHint());
|
||||
_globjList[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user