[vtkusers] VTK and QT headaches

Alex Southern mrapsouthern at gmail.com
Tue Dec 14 09:40:46 EST 2010


Aashish,

Thanks for your reply. I am visualizing wave propagation over time using 
imageData, i require to be able to rotate and zoom using the mouse while 
the image data is being constantly updated and rendered on screen. It is 
the mouse interaction that is very jerky. I am using the new GTX 480 (so 
I know that my system is not the problem here - as my test case is very 
small as well).

So yes I need two threads, the main thread and myThread, as the user 
interaction is an important aspect here. Although I take your point that 
it is easier not to use threads, but in that case I lose the ability to 
interact with the scene while the simulation is running.

With regards the link you sent me.... im really not sure how to apply 
that to my own problem, could you or anyone else elaborate?

Thanks
Alex

On 14.12.2010 16:24, Aashish Chaudhary wrote:
> Hi Alex,
>
> You context is not shared between threads as its indicated in the 
> error. This is nothing new and you can find lot more information if 
> you google for
>
> "OpenGL share context between threads"
>
> It works in second case because Qt is doing the job of signalling the 
> function in other thread in thread safe manner.
>
> But looking at your sample code, I am not sure what kind of 
> interaction issues you are having...
>
> Do you really need two threads? If you do (as I guess you might be 
> loading data in one and displaying in other), there could be ways 
> around it..
>
> May be this link helps giving you more insight:
>
> http://hacksoflife.blogspot.com/2009/08/creating-opengl-textures-or-vbos-on.html 
>
>
>
>
> On Tue, Dec 14, 2010 at 8:45 AM, Alex Southern <mrapsouthern at gmail.com 
> <mailto:mrapsouthern at gmail.com>> wrote:
>
>     Hi,
>
>     Im running a QThread event loop and trying to execute a
>     vtkInteractorWindow->Render() command after each iteration. I have
>     tried two approaches so far but neither work well.
>
>     The First approach, gives a VTK error and is based on something
>     like this:
>     At the initialization stage I pass a pointer to iren. Then in the
>     run() function I execute iren->Render();
>
>     class myThread : public QThread
>     {
>        Q_OBJECT
>
>      public:
>         vtkRenderWindowInteractor *iren;
>         void run();
>        {
>            for (int i = 0; i < 2000; i++)
>            {
>                // process some data
>                iren->Render();
>            }
>        }
>     };
>
>     This compiles but gives the error in the vtkOutputWindow on each
>     call of Render()....
>
>     ERROR: In
>     ..\..\Source\VTKGit\Rendering\vtkWin32OpenGLRenderWindow.cxx, line 247
>     vtkWin32OpenGLRenderWindow (05153168): wglMakeCurrent failed in
>     MakeCurrent(), error: The requested resource is in use.
>
>     The second approach gives no errors, but results in a very jerky
>     interaction. It is implemented by emitting a signal from the for
>     loop after every iteration. The threads myRender() signal is
>     connected to a updateRenderWindow() slot function i.e.
>
>     class myThread : public QThread
>     {
>        Q_OBJECT
>
>      public:
>         void run()
>        {
>            for (int i = 0; i < 2000; i++)
>            {
>                // process some data
>                emit myRender();
>            }
>        }
>      signals:
>         void myRender();
>     };
>
>     class myWindow : public QMainWindow
>     {
>        Q_OBJECT
>
>     public:
>        myThread Td;
>        vtkRenderWindowInteractor *iren;
>
>     public slots:
>        void updateRenderWindow()
>        {
>            iren->Render();
>        }
>     }
>
>
>     Does anyone have any suggestions as to how I can improve either of
>     these methods to give a better interaction?
>
>     Thanks
>     Alex
>
>
>
>     _______________________________________________
>     Powered by www.kitware.com <http://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
>
>     Follow this link to subscribe/unsubscribe:
>     http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
>
> -- 
> | Aashish Chaudhary
> | R&D Engineer
> | Kitware Inc.
> | www.kitware.com <http://www.kitware.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101214/8a79cecf/attachment.htm>


More information about the vtkusers mailing list