# Offscreen rendering opening window

**URL:** https://discourse.vtk.org/t/offscreen-rendering-opening-window/1660
**Category:** Support
**Created:** [August 28, 2019, 4:43pm UTC](https://discourse.vtk.org/t/offscreen-rendering-opening-window/1660 "2019-08-28T16:43:43Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jjackso2](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@jjackso2](https://discourse.vtk.org/u/jjackso2)
#### Post date: [August 28, 2019, 4:43pm UTC](https://discourse.vtk.org/t/offscreen-rendering-opening-window/1660/1 "2019-08-28T16:43:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [August 28, 2019, 11:25pm UTC](https://discourse.vtk.org/t/offscreen-rendering-opening-window/1660/2 "2019-08-28T23:25:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![psandana](https://discourse.vtk.org/user_avatar/discourse.vtk.org/psandana/32/438_2.png) [@psandana](https://discourse.vtk.org/u/psandana)
#### Post date: [November 17, 2020, 9:14pm UTC](https://discourse.vtk.org/t/offscreen-rendering-opening-window/1660/3 "2020-11-17T21:14:32Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [November 17, 2020, 9:20pm UTC](https://discourse.vtk.org/t/offscreen-rendering-opening-window/1660/4 "2020-11-17T21:20:53Z")

</div>

CMake flags have “Mesa” and “offscreen” in their names - see for example [this topic](https://discourse.vtk.org/t/black-image-when-using-offscreen-rendering-inside-qt-application/3935). You can find others on this forum and by googling.

---

<div class="post-metadata">

### Author: ![Rafael\_Scatena](https://discourse.vtk.org/user_avatar/discourse.vtk.org/rafael_scatena/32/7820_2.png) [@Rafael\_Scatena](https://discourse.vtk.org/u/Rafael_Scatena)
#### Post date: [December 21, 2023, 11:22pm UTC](https://discourse.vtk.org/t/offscreen-rendering-opening-window/1660/5 "2023-12-21T23:22:40Z")

</div>

Hello,

Am I obliged to set vtk\_default\_render\_window\_offscreen on cmake or can I set it at runtime?

Thank you

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [December 22, 2023, 3:48am UTC](https://discourse.vtk.org/t/offscreen-rendering-opening-window/1660/6 "2023-12-22T03:48:11Z")

</div>

Off-screen rendering usually works if you just enable it at runtime. However, you may need to adjust cmake variables at build time if you want your rendering to work without an empty window popping up or if you work on a headless node (no display is connected).
