[vtkusers] QT VTK OpenGL errors

Mike Withascarf mikewithascarf at yahoo.com
Thu Nov 3 17:06:29 EDT 2016


In order to reproduce the issue in the latest version of VTK, take the same example I posted before but this time also add a caption to the rendering each time addsphere is called (code below). Then follow the same steps of pushing the button and interacting with the spheres, and it reliably produces the error for me.
#include "SideBySideRenderWindowsQt.h" #include <vtkTextActor.h>#include <vtkTextProperty.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<vtkTextActor> actor_text = vtkSmartPointer<vtkTextActor>::New(); std::string caption; caption = "Testing"; actor_text->SetInput(caption.c_str()); actor_text->SetPosition(8, 8); actor_text->GetTextProperty()->SetFontSize(11); actor_text->GetTextProperty()->SetColor(1.0, 1.0, 1.0);
        vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();         ren->AddActor(actor);  ren->AddActor(actor_text);        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: Ken Martin <ken.martin at kitware.com>
 To: Mike Withascarf <mikewithascarf at yahoo.com> 
Cc: Thales Luis Rodrigues Sabino <tluisrs at gmail.com>; "vtkusers at vtk.org" <vtkusers at vtk.org>
 Sent: Tuesday, November 1, 2016 9:21 PM
 Subject: Re: [vtkusers] QT VTK OpenGL errors
   
Ahh, it very well may be fixed in VTK now. I definitely added some new ways of handling freeing resources to avoid the type of issue you are bumping into.
On Tue, Nov 1, 2016 at 9:20 PM, Mike Withascarf <mikewithascarf at yahoo.com> wrote:

I'm on 7.0.0 currently.
Mike

      From: Ken Martin <ken.martin at kitware.com>
 To: Mike Withascarf <mikewithascarf at yahoo.com> 
Cc: Thales Luis Rodrigues Sabino <tluisrs at gmail.com>; "vtkusers at vtk.org" <vtkusers at vtk.org>
 Sent: Tuesday, November 1, 2016 8:59 PM
 Subject: Re: [vtkusers] QT VTK OpenGL errors
  
What version of VTK are you using? There were some fixes related to that type of issue a few weeks ago.
Thanks!Ken
On Tue, Nov 1, 2016 at 8:01 PM, Mike Withascarf via vtkusers <vtkusers at vtk.org> wrote:

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

   
______________________________ _________________
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





-- 
Ken Martin PhDChairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971
This communication,including all attachments, contains confidential and legally privilegedinformation, and it is intended only for the use of the addressee.  Access to this email by anyone else isunauthorized. If you are not the intended recipient, any disclosure, copying,distribution or any action taken in reliance on it is prohibited and may beunlawful. If you received this communication in error please notify usimmediately and destroy the original message. Thank you.

   



-- 
Ken Martin PhDChairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971
This communication,including all attachments, contains confidential and legally privilegedinformation, and it is intended only for the use of the addressee.  Access to this email by anyone else isunauthorized. If you are not the intended recipient, any disclosure, copying,distribution or any action taken in reliance on it is prohibited and may beunlawful. If you received this communication in error please notify usimmediately and destroy the original message. Thank you.

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


More information about the vtkusers mailing list