[vtkusers] Mesa not rendering scene, but works otherwise

Paul Cochrane cochrane at esscc.uq.edu.au
Thu Mar 17 19:20:45 EST 2005


Randall,

Many thanks for that!  It now seems to work perfectly.  Funny that in other
situations (viewing glyphs for example) calling the Mesa objects directly
works fine.  Thanks again for the tip, it's greatly appreciated.

Paul

* Randall Hand (randall.hand at gmail.com) [050318 00:12]:
> I had a similar problem long ago, and someone tipped me off to the following:
> 
> Don't directly instantiate the vtkMesa* objects.  Instead, put the
> following at the beginning of your code: (C code shown, translate
> appropriately)
> 
>     // Indicate that we want to use Mesa Offscreen
>     vtkGraphicsFactory *factGraphics = vtkGraphicsFactory::New();
>     factGraphics->SetUseMesaClasses(1);
>     factGraphics->Delete();
> 
>     vtkImagingFactory *factImage = vtkImagingFactory::New();
>     factImage->SetUseMesaClasses(1);
>     factImage->Delete();
> 
> Once you do this, the vtk objects will automatically instantiate the
> Mesa equivalents, instead of the OpenGL versions.
> 
> 
> 
> On Thu, 17 Mar 2005 17:53:28 +1000, Paul Cochrane
> <cochrane at esscc.uq.edu.au> wrote:
> > Hi all,
> > 
> > I've got a problem with Mesa not actually rendering a scene, whereas if I
> > don't use Mesa, and just render with the normal (i.e. the ones without Mesa
> > in the name) objects, then the scene displays correctly.  The scene consists
> > of a warped image with the background set to a colour other than the
> > default.  When rendered with Mesa I just get the background.  What am I
> > doing wrong?  (if anything).  I'm using vtk version 4.2.1 (with Mesa enabled),
> > on Linux, and I'm using vtk from Python 2.3.4.
> > 
> > Any help would be greatly appreciated.
> > 
> > Regards,
> > 
> > Paul Cochrane
> > 
> > Here is the test code:  (change mesa to True or False to switch Mesa on or
> > off respectively)
> > 
> > """
> > Load an image, using either Mesa or OpenGL
> > """
> > 
> > import vtk
> > 
> > mesa = True
> > 
> > imgReader = vtk.vtkTIFFReader()
> > imgReader.SetFileName("ausImage_lowres.tif")
> > imgReader.Update()
> > 
> > # now try and warp the data
> > luminance = vtk.vtkImageLuminance()
> > luminance.SetInput(imgReader.GetOutput())
> > 
> > geometry = vtk.vtkImageDataGeometryFilter()
> > geometry.SetInput(luminance.GetOutput())
> > 
> > warp = vtk.vtkWarpScalar()
> > warp.SetInput(geometry.GetOutput())
> > warp.SetScaleFactor(0.0)
> > 
> > # Use vtkMergeFilter to combine the original image with the warped
> > # geometry.
> > merge = vtk.vtkMergeFilter()
> > merge.SetGeometry(warp.GetOutput())
> > merge.SetScalars(imgReader.GetOutput())
> > 
> > mapper = vtk.vtkDataSetMapper()
> > mapper.SetInput(merge.GetOutput())
> > mapper.SetScalarRange(0, 255)
> > mapper.ImmediateModeRenderingOff()
> > 
> > if mesa:
> >     actor = vtk.vtkMesaActor()
> > else:
> >     actor = vtk.vtkActor()
> > actor.SetMapper(mapper)
> > 
> > if mesa:
> >     ren = vtk.vtkMesaRenderer()
> >     renWin = vtk.vtkXMesaRenderWindow()
> >     #renWin.OffScreenRenderingOn()
> > else:
> >     ren = vtk.vtkRenderer()
> >     renWin = vtk.vtkRenderWindow()
> >     renWin.OffScreenRenderingOn()
> > 
> > iren = vtk.vtkRenderWindowInteractor()
> > iren.SetRenderWindow(renWin)
> > 
> > renWin.AddRenderer(ren)
> > 
> > ren.AddActor(actor)
> > 
> > renWin.SetSize(640,480)
> > ren.SetBackground(0.1,0.2,0.4)
> > ren.ResetCameraClippingRange()
> > 
> > iren.Initialize()
> > renWin.Render()
> > iren.Start()
> > 
> > --
> > Paul Cochrane
> > Computational Scientist/Software Developer
> > Earth Systems Science Computational Centre
> > University of Queensland
> > Brisbane
> > Queensland 4072
> > Australia
> > 
> > E: cochrane at esscc.uq.edu.au
> > P: +61 7 3346 9797
> > F: +61 7 3365 7347
> > _______________________________________________
> > 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
> > 
> 
> 
> -- 
> Randall Hand
> http://www.yeraze.com

-- 
Paul Cochrane
Computational Scientist/Software Developer
Earth Systems Science Computational Centre
University of Queensland
Brisbane
Queensland 4072
Australia

E: cochrane at esscc.uq.edu.au
P: +61 7 3346 9797
F: +61 7 3365 7347



More information about the vtkusers mailing list