[vtkusers] How to update the renderer when the data is modified?

Ali - saveez at hotmail.com
Fri Nov 3 11:51:52 EST 2006


Obada,

That is exactly the problem, what Glen described doesn't have anything to do 
with this. If you have a look at the code, you will see that the render() is 
called outside of main() and invoked by AddObserver:

vtkCallbackCommand *cbc = vtkCallbackCommand::New();
cbc->SetCallback(UpdateRenderer);
cbc->SetClientData((void *)viewer);
importer->AddObserver(vtkCommand::Modified, cbc)

where:

static void UpdateRenderer(vtkObject *vtkNotUsed( caller ),
                           unsigned long vtkNotUsed(eventId),
                           void *obj, void *)
{
  vtkImageViewer2* viewer = reinterpret_cast<vtkImageViewer2*>(obj);
  viewer->Render();
}

So render() must be called *outside* of the main thread in order to set the 
event which produces the error you mentioned. Is there any other way of 
doing this?

>
>Hi Ali,
>
>just for the record, any chance that there are multiple threads
>involved in your code?  Depending on what the rest of your code does,
>there might actually be two problems, the "wglMakeCurrent failed"
>error not being related to VTK pipeline updates:
>
>As stated in e.g.
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/opengl/ntopnglr_2u0k.asp
>or
>http://public.kitware.com/pipermail/vtkusers/2004-April/073478.html
>care must be taken when using OpenGL contexts in an environment with
>multiple threads.  I am not sure where that "RenderEvent" is fired
>from in your code, but if it is not from the main thread (more
>precisely, a thread different from the one where vtkImageViewer2 was
>created), that could account for the GL error.
>
>
>Just an idea,
>
>Obada

_________________________________________________________________
Be the first to hear what's new at MSN - sign up to our free newsletters! 
http://www.msn.co.uk/newsletters




More information about the vtkusers mailing list