Offscreen rendering opening window

I want to some offscreen rendering but come across a very annoying problem in linux,
even when I use a vtkWindowToImageFilter as the destination of the render and call
Render() on the render window, it opens the window but only on linux, Windows is behaving
just fine.

Here is a snipper of what I am doing:

   m_RendererSource = vtkWindowToImageFilter::New();
   RenderWindow->SetOffScreenRendering(1);
   ChangeRenderSize(GetSizeX(), GetSizeY(), false);
   m_RendererSource->SetInput(RenderWindow);
   RenderWindow->Render();
   m_RendererSource->Update();

At this point I would only expect the RendererSource to be updated and no window
to popup but in Linux(Ubuntu) it does. I’ve seen solutions on the web bout using Mesa
or overriding the class and remove the call that pops up the window.

Any other solutions readily available in VTK?

Thanks alot!
Jonathan Jackson

You should be able to set up off-screen rendering without a render window in Linux, too, it is just a bit more finicky. Details have been discussed in the VTK forum and mailing list before, but just to give you some hints: there are CMake build flags that control off-screen rendering, order of operations matter (e.g., when you set render window flags and when you initialize the window), and it may make a difference which OpenGL library you use.

Hi @lassoan, can you tell more about the cmake flags? Using VTK 9 with vtkWindowToImageFilter with a multi-layer Renderers in the RenderWindow set by QOpenGLNativeWidget I only can draw the first renderer added.

CMake flags have “Mesa” and “offscreen” in their names - see for example this topic. You can find others on this forum and by googling.