[vtkusers] offscreen rendering on linux

Emptystack wulihouxiaoshuai at 163.com
Wed Oct 8 02:51:11 EDT 2014


I have used the attached code to test offscreen rendering.I works well on
windows os,but on linux a blank window will always appear.I have searched
the relevant topics on the VTK forum,everyone  has different opinion,I have
tried some methods but it failed. Has someone used the VTK to develop
offscreen rendering and GPU accelerated rendering ? Can you give me some
suggestions?

Best wishes!

The following is the test code :

   vtkDICOMImageReader *dicomReader = vtkDICOMImageReader::New();
   dicomReader->SetDirectoryName("D:/image/SER25");
   dicomReader->Update();

  // Create the renderer, render window and interactor
  vtkRenderer *renderer = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
  renWin->AddRenderer(renderer);

  // Connect it all. Note that funny arithematic on the 
  // SetDesiredUpdateRate - the vtkRenderWindow divides it
  // allocated time across all renderers, and the renderer
  // divides it time across all props. If clip is
  // true then there are two props
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);

  
  // Create our volume and mapper
  vtkVolume *volume = vtkVolume::New();
  vtkSmartVolumeMapper *mapper = vtkSmartVolumeMapper::New();
  mapper->SetInputConnection( dicomReader->GetOutputPort() );
   
    

  // Create our transfer function
  vtkColorTransferFunction *colorFun = vtkColorTransferFunction::New();
  colorFun->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0 );
  vtkPiecewiseFunction *opacityFun = vtkPiecewiseFunction::New();
  opacityFun->AddSegment( -500 - 0.5*1500, 0.0, -500 + 0.5*1500, 1.0 );

  // Create the property and attach the transfer functions
  vtkVolumeProperty *property = vtkVolumeProperty::New();
  property->SetIndependentComponents(true);
  property->SetColor( colorFun );
  property->SetScalarOpacity( opacityFun );
  property->SetInterpolationTypeToLinear();

  // connect up the volume to the property and the mapper
  volume->SetProperty( property );
  volume->SetMapper( mapper );


  mapper->SetBlendModeToMaximumIntensity();  


   
   
  // Set the default window size
  renWin->SetSize(600,600);
  renWin->Render();

  // Add the volume to the scene
  renderer->AddVolume( volume );

  renderer->ResetCamera();

  // interact with data
  renWin->Render();

  iren->Start();
  
  opacityFun->Delete();
  colorFun->Delete();
  property->Delete();
  
  volume->Delete();
  mapper->Delete();

  renderer->Delete();
  renWin->Delete();
  iren->Delete();

  return 0;



--
View this message in context: http://vtk.1045678.n5.nabble.com/offscreen-rendering-on-linux-tp5729025.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list