[vtkusers] [python] vtkWin32OpenGLRenderWindow error when calling from thread vtkJPEGWriter.writer method

Gustavo Serra Scalet gsscalet at gmail.com
Mon Nov 19 13:00:49 EST 2007


I had some progress with your tip, thank you David, but unfortunately I'm
having problems with wx too, he doesn't seems to enjoy  being running under
threads...

If I get to something useful I'll comment here.
Bye

2007/11/19, Gustavo Serra Scalet <gsscalet at gmail.com>:
>
> Ok, I'll try to put all VTK stuff on the same thread and controlling from
> another one, that should do
>
> I'll post the results soon... thx already
>
> 2007/11/19, David Cole < david.cole at kitware.com>:
> >
> > VTK objects are not safe for accessing from multiple threads
> > simultaneously. Do all of your VTK object access from the same thread (or,
> > alternatively, use your own locking mechanism to ensure that only one thread
> > at a time may be accessing VTK objects)
> >
> > And if you have a render window (on Windows at least) the GUI thread
> > must access VTK objects to respond to windows WM_ messages. So, generally,
> > you need to restrict access to VTK objects to the same thread that your
> > render window is responding to messages on...
> >
> >
> >
> > On 11/19/07, Gustavo Serra Scalet < gsscalet at gmail.com> wrote:
> >
> > > Hello to all,
> > >
> > > I'm trying to do a recording system that catches what is happening on
> > > the interactor and writes to a file. It has to be a thread or else the
> > > interactor will be unreachable while writing the movie. I've got the same
> > > error when I simplified the problem to just get a jpeg screenshot of the
> > > interactor when using threads. When I just call the method (
> > > self.img.Write) I don't get this error msg and everything goes
> > > perfectly. Can someone tell me what's wrong with my code?
> > >
> > >     def __init__(self, parent):
> > >         from vtk import vtkConeSource, vtkPolyDataMapper, vtkActor,
> > > vtkRenderer
> > >         # creates a dumme Cone
> > >         self.c = vtkConeSource()
> > >         self.c.SetHeight(3)
> > >         self.c.SetRadius(1)
> > >         self.c.SetResolution(10)
> > >         # creates a mapper with the cone
> > >         self.m = vtkPolyDataMapper()
> > >         self.m.SetInput(self.c.GetOutput())
> > >         # sets the actor with the mapper
> > >         self.a = vtkActor()
> > >         self.a.SetMapper(map)
> > >         self.a.SetPosition((0,0,0)) # middle of the screen
> > >         # puts the actor inside the renderer
> > >         self.r = vtkRenderer()
> > >         self.r.SetBackground((0,0,0)) # black bg
> > >         self.r.AddActor(self.a)
> > >         self.r.GetActiveCamera().SetPosition((10,10,10)) # camera at
> > > some position
> > >
> > >         # set the interactor with this renderer, attached to a wx
> > > panel
> > >         from vtk.wx.wxVTKRenderWindowInteractor import
> > > wxVTKRenderWindowInteractor
> > >         self.i = wxVTKRenderWindowInteractor(self.panel , -1 , size =
> > > self.panel.GetSize())
> > >         self.i.GetRenderWindow().AddRenderer(self.r)
> > >         self.i = interactor(self.r,self.panel)
> > >
> > >         # imaging filter
> > >         from vtk import vtkWindowToImageFilter
> > >         self.w2i = vtkWindowToImageFilter()
> > >         self.w2i.SetInput(self.i.GetRenderWindow())
> > >
> > >         # the jpeg object
> > >         from vtk import vtkJPEGWriter
> > >         self.img = vtkJPEGWriter()
> > >         self.img.SetQuality(80) # 80% is good
> > >         self.img.SetInput(self.w2i.GetOutput())
> > >         self.img.SetFileName('01.jpg')
> > >
> > >     def OnGetPictureButton(self, event):
> > >         # threading the image writing
> > >         from thread import start_new_thread
> > >         start_new_thread(self.img.Write,()) # error
> > >         # this way I don't get the error msg
> > >         # self.img.Write()
> > >         event.Skip()
> > >
> > > when "OnGetPictureButton" is called, I get this error on a pop up
> > > screen from vtk:
> > >
> > > "ERROR: In ..\..\VTK-5.0]\Rendering\vtkWin32OpenGLRenderWindow.cxx,
> > > lin
> > > vtkWin32OpenGLRenderWindow(02FE1640): wglMakeCurrent failed in Mak"
> > >
> > > Is it some lock issue?
> > >
> > > thx
> > >
> > > _______________________________________________
> > > This is the private VTK discussion list.
> > > Please keep messages on-topic. Check the FAQ at:
> > > http://www.vtk.org/Wiki/VTK_FAQ
> > > Follow this link to subscribe/unsubscribe:
> > > http://www.vtk.org/mailman/listinfo/vtkusers
> > >
> > >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071119/f6a4d977/attachment.htm>


More information about the vtkusers mailing list