Cleanup offscreen rendering support in VTK.
This commit cleans up offscreen (rather headless) rendering support in VTK. This includes several changes.
-
It makes EGL support independent of onscreen GL support. It's now possible to enable EGL and GLX in same build of VTK, for example, so long as the two use shared GL-dispatch mechanism. Previously, EGL could not be enabled together with GLX (i.e.
VTK_USE_Xset to ON). These changes allow for that configuration. -
VTK_USE_OFFSCREEN_EGLis replaced byVTK_OPENGL_HAS_EGL. This is consistent withVTK_OPENGL_HAS_OSMESAflag. And also in similar vein to upcoming changes toFindOpenGL.cmakewhere EGL becomes a component offind_package(OpenGL). -
VTK_EGL_DEVICE_INDEXhas been replaced byVTK_DEFAULT_EGL_DEVICE_INDEXsince it only affect the default value, and doesn't preclude users from manually specifying the device index. -
VTK_USE_OFFSCREENhas been replaced byVTK_DEFAULT_RENDER_WINDOW_OFFSCREEN, since similar to3this option was only intended to affect the default value. This only changes the default value forvtkRenderWindow::OffscreenRenderingflag. It has no impact on which type of render window is created, for example. -
VTK_DEFAULT_RENDER_WINDOW_HEADLESSis a new option that can be turned on when VTK is compiled with headless and onscreen rendering support. Turning this ON (OFF by default) will make the object factory instantiate the headless render window subclasss whenvtkRenderWindow::Newis called. -
Simplified
FindEGL.cmake. Apps don't need to link againstgldispatchlibrary and hence removed it and created an imported target to simplify use. -
For all changes to CMake variables, we put out
DEPRECATIONmessages if old variables are used. -
When
VTK_USE_XandVTK_OPENGL_HAS_EGLorVTK_OPENGL_HAS_OSMESAin ON, following things happen:- The object-factory simply returns the X-based (or onscreen) render window i.e.
vtkXOpenGLRenderWindow. - To create one of the offscreen render windows, one can manually instantiate them e.g. by explicitly instantiating
vtkEGLRenderWindow.vtkXOpenGLRenderWindowhas implementation to swap to OSMesa ifSetUseOffscreen(true)is called. - As soon any off-screen features are enabled,
glewuses the offscreen library APIs to get OpenGL function pointers irrespective of how the active context was initialized.
- The object-factory simply returns the X-based (or onscreen) render window i.e.
-
Removed all OSMesa code from
vtkXOpenGLRenderWindow. If headless OSMesa offscreen is intended, applications should createvtkOSOpenGLRenderWindow(orvtkEGLRenderWindow), and notvtkXOpenGLRenderWindow.