[vtkusers] offscreen rendering from gui application in vtk8/opengl2

Andreas Buykx A.Buykx at dianafea.com
Mon Jul 9 07:22:55 EDT 2018

I had hoped I would not get this advice as it's rather painful : we have heaps of actors and mappers with associated properties.
This used to work before, was that a lucky accident?

From: Patrick Bergeron <pbergeron at spiria.com>
Sent: maandag 9 juli 2018 1:15
To: Andreas Buykx <A.Buykx at dianafea.com>; 'vtkusers at public.kitware.com' <vtkusers at public.kitware.com>
Subject: Re: offscreen rendering from gui application in vtk8/opengl2

Hi Andreas,

The actors and mappers use OpenGL resources that belong to an OpenGL context, but not all can be shared across multiple OpenGL contexts, especially if one context is software OpenGL (mesaGL?) and the other is not.

Maybe VTK should have a way to clone the renderer and all its contents to do this automatically, or find a way to share shaders across contexts too...

For now here is my recommendation, re-create your scene.

- Create a new render window
- Create a new renderer
- Get all actors in the renderer,  and for each actor:
- Create a new actor
- Create a new mapper
- Set the new mapper to the new actor
- Get the input connection source of the mapper and set it to the new mapper
- Copy the actor's rendering property to the new actor
- Set the user transform of the old actor to the new actor.

Set the active camera from y9our old renderer to new renderer

Copy the lights too if necessary

I think that is it!

From: vtkusers <vtkusers-bounces at public.kitware.com<mailto:vtkusers-bounces at public.kitware.com>> on behalf of Andreas Buykx <A.Buykx at dianafea.com<mailto:A.Buykx at dianafea.com>>
Sent: July 9, 2018 3:42:27 AM
To: 'vtkusers at public.kitware.com'
Subject: [vtkusers] offscreen rendering from gui application in vtk8/opengl2

We recently switched our FEA application from vtk7.1 and the OpenGL backend to using 8.1 and the new OpenGL2 backend.

With 7.1 we could make off-screen images from the gui application using a temporary off-screen render window, temporarily moving renderers from the GUI render window to the off-screen render window, render the image and then move all renderers back to the GUI render window.

With vtk8.1 and OpenGL2 this causes OpenGL errors.

I reproduced this with the attached script which on vtk8.1.1 and the current head leads to an openGL error:

ERROR: In path-to/VTK-master/Rendering/OpenGL2/vtkOpenGLPolyDataMapper.cxx, line 1814

vtkOpenGLPolyDataMapper (0x273dc00): failed after UpdateShader 1 OpenGL errors detected

  0 : (1282) Invalid operation

When the script is run with a global off-screen render window things work out fine.

Is my approach wrong (temporary render window, moving renderers to it temporarily) or is this a bug?

Thanks for your help!


Software Developers and Analysis Consultants for Civil and Geotechnical Engineering

Delftechpark 19a, 2628XJ, Delft, The Netherlands

Tel: +31 88 34262 15 (Direct) │ Tel: +31 88 34262 00 (Switchboard) │ Fax: +31 88 34262 99


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180709/caba151e/attachment.html>

More information about the vtkusers mailing list