Commit 682d5efa authored by Ken Martin's avatar Ken Martin Committed by Kitware Robot

Merge topic 'add_resource_management_to_2d'

a9fa6d3b add opengl resource management to polydatamapper2d
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2144
parents 14e01a70 a9fa6d3b
......@@ -29,6 +29,7 @@
#include "vtkOpenGLPolyDataMapper.h"
#include "vtkOpenGLRenderer.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkOpenGLResourceFreeCallback.h"
#include "vtkOpenGLShaderCache.h"
#include "vtkOpenGLTexture.h"
#include "vtkOpenGLVertexArrayObject.h"
......@@ -64,11 +65,20 @@ vtkOpenGLPolyDataMapper2D::vtkOpenGLPolyDataMapper2D()
this->HaveCellScalars = false;
this->PrimitiveIDOffset = 0;
this->LastPickState = 0;
this->ResourceCallback = new vtkOpenGLResourceFreeCallback<vtkOpenGLPolyDataMapper2D>(this,
&vtkOpenGLPolyDataMapper2D::ReleaseGraphicsResources);
}
//-----------------------------------------------------------------------------
vtkOpenGLPolyDataMapper2D::~vtkOpenGLPolyDataMapper2D()
{
if (this->ResourceCallback)
{
this->ResourceCallback->Release();
delete this->ResourceCallback;
this->ResourceCallback = NULL;
}
if (this->TransformedPoints)
{
this->TransformedPoints->UnRegister(this);
......@@ -96,6 +106,12 @@ vtkOpenGLPolyDataMapper2D::~vtkOpenGLPolyDataMapper2D()
//-----------------------------------------------------------------------------
void vtkOpenGLPolyDataMapper2D::ReleaseGraphicsResources(vtkWindow* win)
{
if (!this->ResourceCallback->IsReleasing())
{
this->ResourceCallback->Release();
return;
}
this->VBO->ReleaseGraphicsResources();
this->Points.ReleaseGraphicsResources(win);
this->Lines.ReleaseGraphicsResources(win);
......@@ -788,6 +804,10 @@ void vtkOpenGLPolyDataMapper2D::RenderOverlay(vtkViewport* viewport,
}
vtkRenderWindow *renWin = vtkRenderWindow::SafeDownCast(viewport->GetVTKWindow());
this->ResourceCallback->RegisterGraphicsResources(
static_cast<vtkOpenGLRenderWindow *>(renWin));
int picking = renWin->GetIsPicking();
if (picking != this->LastPickState)
{
......
......@@ -35,6 +35,7 @@
#include <vector> //for ivars
class vtkActor2D;
class vtkGenericOpenGLResourceFreeCallback;
class vtkMatrix4x4;
class vtkOpenGLBufferObject;
class vtkOpenGLHelper;
......@@ -70,6 +71,8 @@ protected:
vtkOpenGLPolyDataMapper2D();
~vtkOpenGLPolyDataMapper2D();
vtkGenericOpenGLResourceFreeCallback *ResourceCallback;
// the following is all extra stuff to work around the
// fact that gl_PrimitiveID does not work correctly on
// Apple devices with AMD graphics hardware. See apple
......
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