image writing synchronization problem

Peter Blicher blicher at research.nj.nec.com
Fri Nov 26 16:39:03 EST 1999


I think I have a problem with image writing occurring before the renderer
display has finished updating.

I am using vtk 2.4, using the tk interface, and Mesa 3.1beta3 for openGL, on
a redhat 6.1 linux system.

What I need to do is read about 40 data sets of structured grid and texture
from files, render each of these with 3 different lights and camera, and save
the results to either a ppm or bmp file.

I am using:

----------

set w .viewface
set facedata    [lindex $vtk_files 0]
set facetexture [lindex $tex_files 0]

toplevel $w
frame $w.f1
vtkTkRenderWidget $w.f1.r1 -width 512 -height 512
BindTkRenderWidget $w.f1.r1

pack $w.f1.r1 -side left -padx 3 -pady 3 -fill both -expand t
pack $w.f1  -fill both -expand t

# Get the render window associated with the widget.
set renWin [$w.f1.r1 GetRenderWindow]
vtkRenderer $w.ren1
$renWin AddRenderer $w.ren1

proc write_ppm_image {w filebase} {
# Save a ppm image of the render window in widget 'w'.
# from p.126 of users guide for vtk 2.3:
  set renWin [$w.f1.r1 GetRenderWindow]
  # make sure to update display we will save:
  $renWin Render 
  set filename $filebase
  append filename ".render0.ppm"
  $renWin SetFileName $filename
  $renWin SaveImageAsPPM
}

...  a bunch of stuff to set up the camera and lights


write_ppm_image $w $facedata

----------

The last line works fine if I do it manually after the window has been
rendered.  However, if I let it execute in the code above, it just writes an
all black image.  I suspect that this is because the image data is being
saved before Mesa has had a chance to actually render it into the display.

I also tried using the BMP writer method in the user guide (creating a
pipeline coming from a vtkRendererSource), but that behaved identically.

Possibly I am missing something obvious.  However, I can't figure out how to
make sure that some asynchronous rendering is finished before writing the
image file.

Can anyone tell me how to do this?  Obviously for a single dataset, it's no
big deal to do this manually, but eventually I will have hundreds and
hundreds of datasets to do this on.

Thanks.

--peter


-- 
A. Peter Blicher        NEC Research Institute
609-951-2716            4 Independence Way
609-951-2488 fax        Princeton, NJ  08540-6634  USA
blicher at research.nj.nec.com


-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------




More information about the vtkusers mailing list