[vtkusers] Refreshing the vtkRenderWindow

David Gobbi dgobbi at imaging.robarts.ca
Mon Apr 26 13:38:43 EDT 2004


Hi Vivek,

You can only call "Render" from the main thread (i.e. from the thread
that created the vtkRenderWindow).

The proper solution to your problem is to get the device thread to
communicate the coordinate information to the main thread via a mutex
lock (specifically, a vtkMutexLock).

For example, you could have a mutex lock called "renderLock" and four
variables x, y, z and "render":

vtkMutexLock *renderLock = vtkMutexLock::New();
double x, y, z;
int render;

So every time your device wanted to render the window, it would do this:

  renderLock->Lock();
  <set x, y, and z variables>
  render = 1;
  renderLock->Unlock();

Then the main thread would have to check every-so-often to see if the
"render" variable is set, you could add an observer for an interactor
"Timer" event to do this:

  if (render == 1)
    {
    renderLock->Lock();
    <use x, y and z to set up the scene>
    render = 0;
    renderLock->Unlock();
    window->Render();
    }

I have used tricks similar to this for the Flock of Birds, the Logitech
3D Mouse, and the Northern Digital POLARIS in order to separate the
device thread from the main VTK thread.

 - David


On Mon, 26 Apr 2004, Vivek Gupta wrote:

> Hello All,
>
> I have a case where I have a separate thread that is running and
> interfaces with a device.  I use the devices coordinates to update the
> location of an actor (3D cursor on the screen).  I also have
> vtkRenderWindowInteractor associated with vtkRenderWindow so that in the
> window I can use the built-in abilities to manipulate the camera.  What
> I'd like to be able to do is as I manipulate my device is refresh the
> vtkRenderWindow to display the actor at the updated coordinates.
>
> I've tried a variety of methods to do this (vtkRenderWindow->Render(),
> this gives some form of openGL error, which I haven't been able to read)
> and none of them seems to work.  Is there a specific way I have to go
> about getting the reference to vtkRenderWindow or some other way to
> notify it that the actor has been modified so refresh the drawing.  Do I
> have use LevelOfDetail in order to set an auto-refresh rate?
>
> Thanks,
> Vivek
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>





More information about the vtkusers mailing list