Commit 7129b4f6 authored by Ken Martin's avatar Ken Martin

Fix cleanup issue

The weak pointer class sets Context to NULL before the texture resources
are cleaned up.  The destructor for RenWin call ReleaseGraphcisResources.
Modify TextureObject to have ReleaseGraphicsResources method that gets
passed a window so it can work from the destructor.

Change-Id: If66d00268f6d7d6f2a105ef534138e0fe7fd7f57
parent aab8c86a
......@@ -119,8 +119,6 @@ vtkOpenGLImageSliceMapper::vtkOpenGLImageSliceMapper()
this->BackgroundPolyDataActor->SetMapper(polyDataMapper.Get());
}
this->TextureIndex = 0;
this->BackgroundTextureIndex = 0;
this->FragmentShaderIndex = 0;
this->RenderWindow = 0;
this->TextureSize[0] = 0;
......@@ -160,8 +158,6 @@ void vtkOpenGLImageSliceMapper::ReleaseGraphicsResources(vtkWindow *renWin)
this->BackingPolyDataActor->ReleaseGraphicsResources(renWin);
this->PolyDataActor->ReleaseGraphicsResources(renWin);
this->TextureIndex = 0;
this->BackgroundTextureIndex = 0;
this->FragmentShaderIndex = 0;
this->RenderWindow = NULL;
this->Modified();
......
......@@ -105,8 +105,6 @@ protected:
// Check various OpenGL capabilities
void CheckOpenGLCapabilities(vtkOpenGLRenderWindow *renWin);
long TextureIndex; // OpenGL ID for texture or display list
long BackgroundTextureIndex; // OpenGL ID for texture or display list
long FragmentShaderIndex; // OpenGL ID for fragment shader
vtkRenderWindow *RenderWindow; // RenderWindow used for previous render
int TextureSize[2];
......
......@@ -68,7 +68,7 @@ void vtkOpenGLTexture::ReleaseGraphicsResources(vtkWindow *win)
{
if (this->TextureObject && win && win->GetMapped())
{
this->TextureObject->Deactivate();
this->TextureObject->ReleaseGraphicsResources(win);
vtkOpenGLCheckErrorMacro("failed after ReleaseGraphicsResources");
}
......
......@@ -389,6 +389,16 @@ void vtkTextureObject::Deactivate()
}
}
//---------------------------------------------------------------------------
void vtkTextureObject::ReleaseGraphicsResources(vtkWindow *win)
{
vtkOpenGLRenderWindow *rwin =
vtkOpenGLRenderWindow::SafeDownCast(win);
rwin->ActivateTexture(this);
this->UnBind();
rwin->DeactivateTexture(this);
}
//----------------------------------------------------------------------------
void vtkTextureObject::Bind()
{
......
......@@ -24,6 +24,7 @@
#include "vtkObject.h"
#include "vtkWeakPointer.h" // for render context
class vtkWindow;
class vtkOpenGLRenderWindow;
class vtkTexturedActor2D;
......@@ -132,6 +133,9 @@ public:
// Deactivate and UnBind the texture
void Deactivate();
// Description:
// Deactivate and UnBind the texture
void ReleaseGraphicsResources(vtkWindow *win);
// Description:
// Tells if the texture object is bound to the active texture image unit.
......
......@@ -55,7 +55,7 @@ void vtkTextureUnitManager::DeleteTable()
}
if(!valid)
{
vtkErrorMacro(<<"the texture unit is deleted but not some texture unit has not been released: Id="<<i);
vtkErrorMacro(<<"the texture unit is deleted but some texture units have not been released: Id="<<i);
}
delete[] this->TextureUnits;
this->TextureUnits=0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment