Black image when using offscreen rendering inside Qt application

I have written a library, which shall produce some rendering of scenes into images using VTK (no actual interactive 3D windows).

I have two executables from which the library is used: one command line tool and a Qt based GUI application. Using the library from the command line tool works all as expected. When called from the GUI application, the programm creates only a black image.

some more informations:

  • I use VTK8.2.0 (which comes along and is compiled together with Paraview 5.6)
  • Paraview was configured with these flags:

Ok, I found that this issue is caused not by Qt but by some third library (OpenCASCADE). I’m investigating further.

I tried a lot of options/updates etc to nail this issue down but I could not finish it yet.

I currently reduced it to this: My Qt-application with an embedded OpenCASCADE-View-Widget runs ok. As soon as I add ${VTK_LIBRARIES} to the “target_link_libraries” statement in my CMakeLists.txt (without adding any code, that actually uses VTK), the application fails to run with an OpenGL issue.

VTK is detected by this statement:


It looks like there is something implicitly initialized in one of the VTK libraries which causes trouble. What might this be?

I just updated to Paraview 5.8 with VTK-9. I still built it with OSMesa and offscreen rendering by default (actually I only want to do offscreen renderings with VTK).

Any ideas @ben.boeckel ?

This sounds like more of a question for @utkarshayachit or @ken-martin to me.

Hi, we had similar problems to this. I think it is related to OpenGL state. We resolved it by calling Render() at the right time. Try calling Render() before your scene rendering. We never figured out why this helped or what was wrong, but it worked…

Meanwhile, I’m wondering whether my dependency situation supposed to work at all or if it is expected to fail due to conflicts. I tried to sketch it here:

With OSMesa, problems occur in the GUI application, when the OpenCASCADE viewer is initialized.
I could make it work, if I build Paraview with “VTK_OPENGL_HAS_OSMESA” and “VTK_OPENGL_HAS_EGL” both set to “OFF”. Unfortunately, it does not work on a headless machine without “DISPLAY” variable then.

I’m a bit confused about the current state in Paraview. In earlier versions, I needed separate a build with OSMesa to enable headless operation. Recently, I read about switching between onscreen and offscreen rendering. But that does not include switching between hardware rendering and software OSMesa, right?

Thanks for any hint, Hannes