This seemingly innocuous code has a serious flaw. You’re actually grabbing undefined contents! Let’s look at what’s going on a little more closely.

vtkRenderWindow, by default, is setup to use double-buffering. When using double-buffering, it is also setup to swap back and front buffers at the end of each render. The kicker is that despite its name (and common perception), this swap is not defined as a true swap. It merely implies back buffer contents being copied to the front buffer. What is left in the back buffer at the end of the swap is not defined. As a result, when vtkWindowToImage filter goes to grab the back-buffer after the render, it invariable is reading undefined contents — although one may be getting lucky in most cases.