[vtkusers] threads and refreshing vtkRenderWindow
Giancarlo Amati
ilferraresebono at hotmail.it
Mon May 18 05:14:08 EDT 2009
Nope I don't,....I was just telling you how I did organize my code...and as you said the Render() function should be called only from the thread that the MAIN one, I was simply asking..if calling a function which belongs to the main thread (which is the Parent from the 2nd one) is the reason that generates the wglMakeCurrent error.
Moreover, as the documentation about the vtkMutexLock class on the vtk website is quite poor, I was just wondering if there were any other resource.
My project is mainly about a device system which tracks IReds visulalized with VTK, basically what I am doing is a real-time animation with QT and VTK. So, as I need to update the VTK scene without interfering with the QT events, the QT users group told me that the best way is to create a thread which updates the scene. But apparently this generates a wglMakeCurrent error for the reasons you told me.
GC.
Date: Fri, 15 May 2009 11:08:20 -0400
Subject: Re: [vtkusers] threads and refreshing vtkRenderWindow
From: david.cole at kitware.com
To: ilferraresebono at hotmail.it
CC: vtkusers at vtk.org
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!
_______________________________________________
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!
_________________________________________________________________
Più di 100 Emoticon gratis per il tuo Messenger!
http://intrattenimento.it.msn.com/emoticon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090518/5a09ed9c/attachment.htm>
More information about the vtkusers
mailing list