[vtkusers] QT VTK OpenGL errors

Mike Withascarf mikewithascarf at yahoo.com
Tue Nov 1 20:01:23 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(); 
} 

      From: Thales Luis Rodrigues Sabino <tluisrs at gmail.com>
 To: Mike Withascarf <mikewithascarf at yahoo.com> 
Cc: "vtkusers at vtk.org" <vtkusers at vtk.org>
 Sent: Tuesday, November 1, 2016 7:19 PM
 Subject: Re: [vtkusers] QT VTK OpenGL errors
   
This looks like an OpenGL resource sharing issue. I don't know exactly how VTK handles multiples windows in a Qt application but it looks like it is trying to bind a texture that is not registered in a certain context.
Can tell if this happens when you have a single window or this happens only when you add a second window?
On Tue, Nov 1, 2016 at 8:15 PM, Mike Withascarf via vtkusers <vtkusers at vtk.org> wrote:

I'm using QT with VTK for a fairly complex application. Everything works fine
normally, but if I try to use a function to 'clear' the QVTKWidget, and then
add a new pipeline, I run into lots of OpenGL errors. What would be the
appropriate way to clear the window/renderer? Here is the code I've been
trying, where window is of type QVTKWidget:

vtkSmartPointer<vtkRenderer> ren_old =
window->GetRenderWindow()-> GetRenderers()-> GetFirstRenderer();
if (ren_old) ren_old->RemoveAllViewProps(); // Remove the pipeline from
renderer
if (window->isVisible() && window->GetRenderWindow()-> IsDrawable())
window->GetRenderWindow()-> Render(); // Update the window so it is blank
if (ren_old) window->GetRenderWindow()-> RemoveRenderer(ren_old); // Remove
the renderer



I'm using multiple QVTKWidgets in one app, and each might have a pipeline
that connects either with vtkImageViewer2 or a normal vtkRenderer. Here are
the OpenGL errors reported in the vtkOutputWindow:

ERROR: In C:\vtk\src\Rendering\OpenGL2\ vtkTextureObject.cxx, line 540
vtkTextureObject (0000029AC7337C70): failed at glBindTexture 1 OpenGL errors
detected
  0 : (1282) Invalid operation


ERROR: In C:\vtk\src\Rendering\OpenGL2\ vtkTextureObject.cxx, line 554
vtkTextureObject (0000029AC7337C70): failed at glBindTexture(0) 1 OpenGL
errors detected
  0 : (1282) Invalid operation


ERROR: In C:\vtk\src\Rendering\OpenGL2\ vtkTextureObject.cxx, line 540
vtkTextureObject (0000029AC7337C70): failed at glBindTexture 1 OpenGL errors
detected
  0 : (1282) Invalid operation


ERROR: In C:\vtk\src\Rendering\OpenGL2\ vtkTextureObject.cxx, line 554
vtkTextureObject (0000029AC7337C70): failed at glBindTexture(0) 1 OpenGL
errors detected
  0 : (1282) Invalid operation

______________________________ _________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/ opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_ FAQ

Search the list archives at: http://markmail.org/search/?q= vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/ mailman/listinfo/vtkusers





-- 
Thales Luis Rodrigues Sabino
PhD Student at PGMC-UFJFLattes | LinkedIn | ResearchGate

   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161102/845c6268/attachment.html>


More information about the vtkusers mailing list