[vtkusers] Hide XWindow when offscreen-rendering

Lars Friedrich Lars lars-friedrich at gmx.net
Tue Apr 27 10:03:59 EDT 2010


Hello,

I would like to know whether or not it is possible to hide the X-window automatically generated by vtkXOpenGLRenderWindow on Linux systems? For example the attached code below runs without popping up a window on MSWindows, but pops up the window on Linux.

Does someone know how I could switch the XWindow invisible? Is there a possibility to do this with 'x-commands'? For example in MSWindows I could theoretically get the handle the window and then call some API function to set the window invisible. Is there a similar possibility when using vtkXOpenGLRenderWindow?

Thank you!

regards,

lars


#include <stdlib.h>

#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkActor.h>
#include <vtkConeSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkWindowToImageFilter.h>
#include <vtkPNGWriter.h>
#include <vtkProperty.h>

int main(int argc, char *argv[])
{
  vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
  vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
  renWin->AddRenderer(ren);
  renWin->SetOffScreenRendering(true);
  renWin->SetSize(300, 200);

  vtkSmartPointer<vtkConeSource> cone = vtkSmartPointer<vtkConeSource>::New();
  vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(cone->GetOutputPort());
  vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
  actor->GetProperty()->SetColor(1, 0, 0);
  ren->AddActor(actor);
  ren->ResetCamera();

  vtkSmartPointer<vtkPNGWriter> w = vtkSmartPointer<vtkPNGWriter>::New();
  vtkSmartPointer<vtkWindowToImageFilter> w2i = vtkSmartPointer<vtkWindowToImageFilter>::New();
  w2i->SetInput(renWin);
  w2i->SetInputBufferTypeToRGB();
  w2i->SetMagnification(1);
  w2i->ShouldRerenderOn();
  w->SetInput(w2i->GetOutput());
  w->SetFileName("cone.png");
  w->Write();

  return EXIT_SUCCESS;
}

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01



More information about the vtkusers mailing list