[vtkusers] threads and refreshing vtkRenderWindow

David Cole david.cole at kitware.com
Fri May 15 11:08:20 EDT 2009


Are you asking us to tell you how your program is organized with respect to
threads? (That's somewhat beyond the scope of the VTK mailing list.)
It sounds like your project might be better off single-threaded.

It would be better if you call UpdateMy3DObject from the same thread that
actually does the rendering.


On Fri, May 15, 2009 at 10:59 AM, Giancarlo Amati <
ilferraresebono at hotmail.it> wrote:

>  Many thanks,
>
> what I have is a mainWindow which has functions for rendering and then a
> thread that calls a kind of "UpdateMy3Dobjects" function which belongs to
> the mainWindow object. Now,
> this "UpdateMy3DObjects" function works fine whenever that thread is not
> running while, I got the wglMakeCurrent error as soon as the thread runs the
> UpdateMy3Dobjects" function.
> So,
> as the UpdateMy3Dobjects function calls the RenderWindow->Render() method
> (renderwindow buidt in a QVTKWidget object of my GUI) calling that
> UpdateMy3DObject from the thread does correspond to a call form a thread
> different from the main one?
> In that case if I create a global variable, boolean for example which is
> true when I execute the UpdateMy3DObject function and false
> otherwise...would it help to synchronize these threads?
>
> I checked out on the VTK documentation and I found the vktMutexLock
> class....and i tried to understand the example in the documetation which is
> a bit difficult honestly, but,....can that class be useful for my project?
>
> many kind regards.
> Giancarlo
>
> ------------------------------
> Date: Fri, 15 May 2009 10:19:51 -0400
> Subject: Re: [vtkusers] threads and refreshing vtkRenderWindow
> From: david.cole at kitware.com
> To: ilferraresebono at hotmail.it
> CC: vtkusers at vtk.org
>
>
> I will not claim to be cleverer, but I think I can answer the question:
> Your mistake is calling vtkObjects from multiple threads without
> synchonization objects. In general, vtkObjects are only safely accessible by
> one thread at a time. Multi-thread access means you will have to use some
> sort of mutexes or locks to guarantee that only one thread at a time will
> call vtkObject methods. Furthermore, you should only attempt to call Render
> from the main GUI thread of your application.
>
>
> Hope this helps,
> David
>
>
> On Fri, May 15, 2009 at 9:25 AM, Giancarlo Amati <
> ilferraresebono at hotmail.it> wrote:
>
>  Hello vtkUSERS!!! This is an ash question for only the cleverer!! :D
>
> I have a thread which modifies some data already in the vtkRenderWindow.,
> now, the problem I have is when I want to refresh the window.
> I though calling something like renderWindow->Render() or
> renderer->render(), but I get some error messages related to "Resource
> already in use" and "wglMakeCurrent()" function error.
>
> Where is my mistake and any idea about how to overcome it?
>
> Kind regards.
>
> GC.
>
> ------------------------------
> Scrivi, parla e gioca con i tuoi amici! Scarica Messenger 2009!<http://messenger.it/gioca.aspx>
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>
> ------------------------------
> Quali sono le parole più cliccate? Scopri la top!<http://livesearch.it.msn.com/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090515/74514614/attachment.htm>


More information about the vtkusers mailing list