[vtkusers] QT VTK OpenGL errors

Ken Martin ken.martin at kitware.com
Fri Nov 4 14:14:20 EDT 2016


Great, thanks for your help in tracking it down!

On Fri, Nov 4, 2016 at 2:12 PM, Mike Withascarf <mikewithascarf at yahoo.com>
wrote:

> That does appear to have solved it. Thanks for all your help!
>
> 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:* Friday, November 4, 2016 9:10 AM
> *Subject:* Re: [vtkusers] QT VTK OpenGL errors
>
> Awesome!  Given the changes you made I'm 90% sure I know what the problem
> is and it is a fairly easy fix. Here is a merge request that contains a fix
> (not tested on your example so if you have a sec to test it please do)
>
> https://gitlab.kitware.com/vtk/vtk/merge_requests/2144
>
>
>
> On Thu, Nov 3, 2016 at 5:06 PM, Mike Withascarf <mikewithascarf at yahoo.com>
> wrote:
>
> 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
> <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
> <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 <http://www.vtk.org/Wiki/VTK_FAQ>
>
> Search the list archives at: http://markmail.org/search/?q= vtkusers
> <http://markmail.org/search/?q=vtkusers>
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/ mailman/listinfo/vtkusers
> <http://public.kitware.com/mailman/listinfo/vtkusers>
>
>
>
>
> --
> Thales Luis Rodrigues Sabino
>
> PhD Student at PGMC-UFJF <http://www.ufjf.br/pgmc/>
> Lattes <http://lattes.cnpq.br/0601030410417146> | LinkedIn
> <https://br.linkedin.com/in/tluisrs> | ResearchGate
> <https://www.researchgate.net/profile/Thales_Luis_Sabino>
>
>
>
> ______________________________ _________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
> <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 <http://www.vtk.org/Wiki/VTK_FAQ>
>
> Search the list archives at: http://markmail.org/search/?q= vtkusers
> <http://markmail.org/search/?q=vtkusers>
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/ mailman/listinfo/vtkusers
> <http://public.kitware.com/mailman/listinfo/vtkusers>
>
>
>
>
> --
> Ken Martin PhD
> Chairman & CFO
> Kitware Inc.
> 28 Corporate Drive
> Clifton Park NY 12065
> 518 371 3971
>
> This communication, including all attachments, contains confidential and
> legally privileged information, and it is intended only for the use of the
> addressee.  Access to this email by anyone else is unauthorized. If you are
> not the intended recipient, any disclosure, copying, distribution or any
> action taken in reliance on it is prohibited and may be unlawful. If you
> received this communication in error please notify us immediately and
> destroy the original message.  Thank you.
>
>
>
>
>
> --
> Ken Martin PhD
> Chairman & CFO
> Kitware Inc.
> 28 Corporate Drive
> Clifton Park NY 12065
> 518 371 3971
>
> This communication, including all attachments, contains confidential and
> legally privileged information, and it is intended only for the use of the
> addressee.  Access to this email by anyone else is unauthorized. If you are
> not the intended recipient, any disclosure, copying, distribution or any
> action taken in reliance on it is prohibited and may be unlawful. If you
> received this communication in error please notify us immediately and
> destroy the original message.  Thank you.
>
>
>
>
>
> --
> Ken Martin PhD
> Chairman & CFO
> Kitware Inc.
> 28 Corporate Drive
> Clifton Park NY 12065
> 518 371 3971
>
> This communication, including all attachments, contains confidential and
> legally privileged information, and it is intended only for the use of the
> addressee.  Access to this email by anyone else is unauthorized. If you are
> not the intended recipient, any disclosure, copying, distribution or any
> action taken in reliance on it is prohibited and may be unlawful. If you
> received this communication in error please notify us immediately and
> destroy the original message.  Thank you.
>
>
>


-- 
Ken Martin PhD
Chairman & CFO
Kitware Inc.
28 Corporate Drive
Clifton Park NY 12065
518 371 3971

This communication, including all attachments, contains confidential and
legally privileged information, and it is intended only for the use of the
addressee.  Access to this email by anyone else is unauthorized. If you are
not the intended recipient, any disclosure, copying, distribution or any
action taken in reliance on it is prohibited and may be unlawful. If you
received this communication in error please notify us immediately and
destroy the original message.  Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161104/90c41a68/attachment-0001.html>


More information about the vtkusers mailing list