[vtkusers] black image

Keyan Mehravaran keyanm at yahoo.com
Thu Feb 7 14:20:31 EST 2008


Hello,

I've compiled vtk for pure Mesa, using Enable VTK_OPENGL_HAS_OSMESA, and
wrappers for python, and have read the forum for off screen rendering tricks as
well.
Now, the code attached, produces only a black png, and I don't know what's the
reason. If I comment the line:
renWin.OffScreenRenderingOn()
then I can see a cone coming and quickly disappearing, but still nothing in the
png (340 bytes).
Thank you for your help.
Kian Mehravaran
#!/usr/bin/env python

import vtk

graphics_factory = vtk.vtkGraphicsFactory()
graphics_factory.SetOffScreenOnlyMode(1)
graphics_factory.SetUseMesaClasses(1)

# Imaging Factory
imaging_factory = vtk.vtkImagingFactory()
imaging_factory.SetUseMesaClasses(1)

renWin = vtk.vtkRenderWindow()

# Will render in memory.
renWin.OffScreenRenderingOn()

ren = vtk.vtkRenderer()
renWin.AddRenderer(ren)

#vtkConeSource cone
cone = vtk.vtkConeSource()

mp = vtk.vtkPolyDataMapper()
mp.SetInputConnection(cone.GetOutputPort())

actor = vtk.vtkActor()
actor.SetMapper(mp)

ren.AddActor(actor)

renWin.Render()

# Save the window to a png file
w2if = vtk.vtkWindowToImageFilter()
w2if.SetInput(renWin)

#vtkPNGWriter wr
wr = vtk.vtkPNGWriter()
wr.SetInputConnection(w2if.GetOutputPort())
wr.SetFileName("test.png")
wr.Write()



      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs



More information about the vtkusers mailing list