[vtkusers] socket communication

Simon Drouin sdrouin at bic.mni.mcgill.ca
Wed Feb 2 10:17:14 EST 2005


jean-michel.rouet at philips.com wrote:

>
> Hi all,
>
> I'm trying to do the following.
>
> A vtk application A (the server) that renders a scene and has an 
> interactor
> an other vtk application B (the client) that renders an onther scene 
> and has also an interactor
>
> (in fact A and B are the same program ran twice)
>
> What I'd like to achieve is this:
> Whenever the user changes the camera in application A, the camera of 
> the application B is updated accordingly.
> but when the user moves the camera in B, the camera is not changed in A.
>
> I managed to do almost what I want using a socket communication.
> a callback that reacts on camera modifed events in A sends through the 
> socket the position of the camera, the focal point and the viewup vector.
>
> application B listens to the socket and updates its own camera.
> Unfortunately, this listening is blocking the interface of B.
>
> Then I tried to set the socket listenner of B in a spawned thread so 
> that the main interaction loop continues to occur.
> But then, the renderer->Render() call in the thread fails saying that: "
> vtkWin32OpenGLRenderWindow (018F0F40): wglMakeCurrent failed in 
> MakeCurrent(), error: resource in use" (translation from french La 
> ressource demandée est en cours d'utilisation).
>
> What is the solution then ?
>
>------------------------------------------------------------------------
>
>_______________________________________________
>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
>  
>
Hi,

Rendering from a different thread than the main thread is never a good 
idea. Your listener thread should just post an event to the main loop 
when it receives a camera event from the socket. When the main loop 
processes the event, then you can call Render(). I do that with Qt under 
linux (QApplication::postEvent()), but it is probably as easy to do 
using Windows.

Simon Drouin



More information about the vtkusers mailing list