[vtkusers] QT VTK OpenGL errors

mikewithascarf mikewithascarf at yahoo.com
Tue Nov 1 20:00:04 EDT 2016


That's right, the problem only happens if there are more than one QVTKWidget.

I've managed to create a fairly simple example to reproduce the problem:

https://drive.google.com/open?id=0BxalkOjn2_PecG5kUUZrN2djMlU

It's a very basic modification of the SideBySideRenderWindowsQt example
provided by VTK. I've simply added a button, and when it's clicked it will
clear the left window and add a sphere, then clear the right window and add
a sphere. If I do the following it produces the OpenGL errors every time for
me:

1. Click the button.
2. Manually rotate both spheres.
3. Click the button.
4. Manually rotate both spheres.
5. Click the button.
6. Manually rotate both spheres. (You'll get the errors here)

Here's the code below. Interestingly if I move both clear calls before both
of the addsphere calls it works fine. Unfortunately that approach won't work
for my app (needs to be able to change a single window).


#include "SideBySideRenderWindowsQt.h"

void addsphere(vtkSmartPointer<vtkRenderWindow> renwin)
{
	vtkSmartPointer<vtkSphereSource> sphereSource =
		vtkSmartPointer<vtkSphereSource>::New();
	sphereSource->SetCenter(0.0, 0.0, 0.0);
	sphereSource->SetRadius(5.0);

	vtkSmartPointer<vtkPolyDataMapper> mapper =
		vtkSmartPointer<vtkPolyDataMapper>::New();
	mapper->SetInputConnection(sphereSource->GetOutputPort());

	vtkSmartPointer<vtkActor> actor =
		vtkSmartPointer<vtkActor>::New();
	actor->SetMapper(mapper);

	vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
	ren->AddActor(actor);
	ren->ResetCameraClippingRange();

	renwin->AddRenderer(ren);
	renwin->Render();
}

void clear(vtkSmartPointer<vtkRenderWindow> renwin)
{
	// clear renderer
	vtkSmartPointer<vtkRenderer> ren =
		renwin->GetRenderers()->GetFirstRenderer();
	if (ren)
	{
		ren->RemoveAllViewProps();
		renwin->Render();
		renwin->RemoveRenderer(ren);
	}
}

// Constructor
SideBySideRenderWindowsQt::SideBySideRenderWindowsQt() 
{
  this->setupUi(this);

  QObject::connect(b1, SIGNAL(released()), this, SLOT(slot_b1()));

  // Set up action signals and slots
  connect(this->actionExit, SIGNAL(triggered()), this, SLOT(slotExit()));
}

void SideBySideRenderWindowsQt::slot_b1()
{
	clear(this->qvtkWidgetLeft->GetRenderWindow());

	addsphere(this->qvtkWidgetLeft->GetRenderWindow());
	this->qvtkWidgetLeft->GetRenderWindow()->Render();

	clear(this->qvtkWidgetRight->GetRenderWindow());
	
	addsphere(this->qvtkWidgetRight->GetRenderWindow());
	this->qvtkWidgetRight->GetRenderWindow()->Render();
}

void SideBySideRenderWindowsQt::slotExit() 
{
  qApp->exit();
}




--
View this message in context: http://vtk.1045678.n5.nabble.com/QT-VTK-OpenGL-errors-tp5740999p5741002.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list