Commit d0e7aab3 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit
Browse files

Cleanup offscreen rendering support in VTK.

This commit cleans up offscreen rendering support in VTK. This includes
several changes.

1. 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_X` set to ON). These changes allow for that
   configuration.

2. `VTK_USE_OFFSCREEN_EGL` is replaced by `VTK_OPENGL_HAS_EGL`.
    This is consistent with `VTK_OPENGL_HAS_OSMESA` flag. And also
    in similar vein to changes to `FindOpenGL.cmake` where EGL
    becomes a component of `find_package(OpenGL)`.

3. `VTK_EGL_DEVICE_INDEX` has been replaced by
   `VTK_DEFAULT_EGL_DEVICE_INDEX` since it only affect the default
   value, and doesn't preclude users from manually specifying the
   device index.

4. `VTK_USE_OFFSCREEN` has been replaced by
   `VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN`, since similar to `3`
   this option was only intended to affect the default value.

5. Simplified `FindEGL.cmake`. Apps don't need to link against
   `gldispatch` library and hence removed it and created an
   imported target to simplify use.

6. For all changes to CMake variables, we put out `DEPRECATION`
   messages if old variables are used.

7. When `VTK_USE_X` and `VTK_OPENGL_HAS_EGL` or
   `VTK_OPENGL_HAS_OSMESA` in ON, following things happen:
   i.   The object-factory simply returns the X-based (or
        onscreen) render window i.e. `vtkXOpenGLRenderWindow`.
   ii.  To create one of the offscreen render windows, one can
        manually instantiate them e.g. by explicitly
        instantiating `vtkEGLRenderWindow`.
        `vtkXOpenGLRenderWindow` has implementation to swap to
        OSMesa if `SetUseOffscreen(true)` is called.
   iii. As soon any off-screen features are enabled, `glew`
        uses the offscreen library APIs to get OpenGL function pointers
        irrespective of how the active context was initialized.
parent edd75a97
# Try to find EGL library and include dir. #.rst:
# Once done this will define # FindEGL
# -------
# #
# EGL_FOUND - true if EGL has been found # Find the EGL library.
# EGL_INCLUDE_DIR - where the EGL/egl.h and KHR/khrplatform.h can be found #
# EGL_LIBRARY - link this to use libEGL.so.1 # Imported Targets
# EGL_opengl_LIBRARY - link with these two libraries instead of the gl library # ^^^^^^^^^^^^^^^^
# EGL_gldispatch_LIBRARY for full OpenGL support through EGL #
# EGL_LIBRARIES - all EGL related libraries: EGL, OpenGL, GLdispatch # This module defines the following :prop_tgt:`IMPORTED` targets:
#
# ``EGL::EGL``
if(NOT EGL_INCLUDE_DIR) # The EGL library, if found.
#
# If we have a root defined look there first # ``EGL::OpenGL``
if(EGL_ROOT) # The OpenGL library, if found.
find_path(EGL_INCLUDE_DIR EGL/egl.h PATHS ${EGL_ROOT}/include #
NO_DEFAULT_PATH # Result Variables
) # ^^^^^^^^^^^^^^^^
endif() #
# This module will set the following variables in your project:
if(NOT EGL_INCLUDE_DIR) #
find_path(EGL_INCLUDE_DIR EGL/egl.h PATHS # ``EGL_FOUND``
/usr/local/include # System has the EGL library.
/usr/include # ``EGL_INCLUDE_DIR``
) # The EGL include directory.
endif() # ``EGL_LIBRARY``
endif() # The libEGL library.
# ``EGL_LIBRARIES``
if(NOT EGL_LIBRARY) # All EGL related libraries, including ``EGL_LIBRARY``.
# If we have a root defined look there first #
if(EGL_ROOT) # Hints
find_library(EGL_LIBRARY EGL PATHS ${EGL_ROOT}/lib # ^^^^^
NO_DEFAULT_PATH #
) # Set `EGL_ROOT_DIR` to the root directory of an EGL installation.
endif() find_path(EGL_INCLUDE_DIR
NAMES
EGL/egl.h
PATHS
${EGL_ROOT_DIR}/include
/usr/local/include
/usr/include)
if(NOT EGL_LIBRARY) find_library(EGL_LIBRARY
find_library(EGL_LIBRARY EGL PATHS NAMES
/usr/local/lib EGL
/usr/lib PATHS
) ${EGL_ROOT_DIR}/lib
endif() /usr/local/lib
endif() /usr/lib)
if(NOT EGL_opengl_LIBRARY) find_library(EGL_opengl_LIBRARY
# If we have a root defined look there first NAMES
if(EGL_ROOT) OpenGL
find_library(EGL_opengl_LIBRARY OpenGL PATHS ${EGL_ROOT}/lib PATHS
NO_DEFAULT_PATH ${EGL_ROOT_DIR}/lib
) /usr/local/lib
endif() /usr/lib)
if(NOT EGL_opengl_LIBRARY) set(EGL_LIBRARIES ${EGL_LIBRARY} ${EGL_opengl_LIBRARY})
find_library(EGL_opengl_LIBRARY OpenGL PATHS
/usr/local/lib
/usr/lib
)
endif()
endif()
if(NOT EGL_gldispatch_LIBRARY) include(FindPackageHandleStandardArgs)
# If we have a root defined look there first find_package_handle_standard_args(
if(EGL_ROOT) EGL DEFAULT_MSG
find_library(EGL_gldispatch_LIBRARY GLdispatch PATHS ${EGL_ROOT}/lib EGL_LIBRARY EGL_opengl_LIBRARY EGL_INCLUDE_DIR)
NO_DEFAULT_PATH mark_as_advanced(EGL_ROOT_DIR EGL_INCLUDE_DIR EGL_LIBRARY EGL_opengl_LIBRARY)
)
endif()
if(NOT EGL_gldispatch_LIBRARY) if(EGL_FOUND)
find_library(EGL_gldispatch_LIBRARY GLdispatch PATHS add_library(EGL::OpenGL UNKNOWN IMPORTED)
/usr/local/lib set_target_properties(EGL::OpenGL PROPERTIES
/usr/lib INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}")
) set_target_properties(EGL::OpenGL PROPERTIES
endif() IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${EGL_opengl_LIBRARY}")
# For the NVIDIA 358 drivers there isn't a libGLdispath.so. The add_library(EGL::EGL UNKNOWN IMPORTED)
# proper one gets installed as libGLdispatch.so.0. set_target_properties(EGL::EGL PROPERTIES
if(NOT EGL_gldispatch_LIBRARY) INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}")
find_library(EGL_gldispatch_LIBRARY libGLdispatch.so.0 PATHS set_target_properties(EGL::EGL PROPERTIES
/usr/local/lib IMPORTED_LINK_INTERFACE_LANGUAGES "C"
/usr/lib INTERFACE_LINK_LIBRARIES "EGL::OpenGL"
) IMPORTED_LOCATION "${EGL_LIBRARY}")
endif()
endif() endif()
set(EGL_LIBRARIES ${EGL_LIBRARY} ${EGL_opengl_LIBRARY} ${EGL_gldispatch_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(EGL DEFAULT_MSG
EGL_LIBRARY EGL_opengl_LIBRARY EGL_gldispatch_LIBRARY EGL_INCLUDE_DIR)
mark_as_advanced(EGL_DIR EGL_INCLUDE_DIR EGL_LIBRARY EGL_opengl_LIBRARY EGL_gldispatch_LIBRARY)
# Logic to figure out what system libraries will be used by rendering, and # Logic to figure out what system libraries will be used by rendering, and
# whether VTK can use OSMesa for rendering. # whether VTK can use OSMesa for rendering.
set(VTK_USE_X_DEFAULT OFF) set(default_use_x OFF)
# For each platform specific API, we define VTK_USE_<API> options.
if(APPLE AND NOT APPLE_IOS) if(APPLE AND NOT APPLE_IOS)
option(VTK_USE_COCOA "Use Cocoa for VTK render windows" ON) option(VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
mark_as_advanced(VTK_USE_COCOA) mark_as_advanced(VTK_USE_COCOA)
...@@ -11,63 +12,95 @@ if(APPLE AND NOT APPLE_IOS) ...@@ -11,63 +12,95 @@ if(APPLE AND NOT APPLE_IOS)
message(FATAL_ERROR "Carbon support has been removed, but it appears that it was requested. If you require Carbon support, use VTK 6.x. Otherwise, turn off the VTK_USE_CARBON option.") message(FATAL_ERROR "Carbon support has been removed, but it appears that it was requested. If you require Carbon support, use VTK 6.x. Otherwise, turn off the VTK_USE_CARBON option.")
endif () endif ()
elseif(UNIX AND NOT ANDROID AND NOT APPLE_IOS) elseif(UNIX AND NOT ANDROID AND NOT APPLE_IOS)
set(VTK_USE_X_DEFAULT ON) set(default_use_x ON)
endif() endif()
option(VTK_USE_X "Use X for VTK render windows" ${VTK_USE_X_DEFAULT}) option(VTK_USE_X "Use X for VTK render windows" ${default_use_x})
mark_as_advanced(VTK_USE_X)
# OSMesa logic for offscreen mesa rendering. # For optional APIs that could be available for the OpenGL implementation
# being used, we define VTK_OPENGL_HAS_<feature> options. These are not to be
# treated as mutually exclusive.
#-----------------------------------------------------------------------------
# OSMesa variables
#-----------------------------------------------------------------------------
# OpenGL implementation supports OSMesa for creating offscreen context.
option(VTK_OPENGL_HAS_OSMESA option(VTK_OPENGL_HAS_OSMESA
"The OpenGL library being used supports off screen Mesa calls" OFF) "The OpenGL library being used supports offscreen Mesa (OSMesa)" OFF)
mark_as_advanced(VTK_OPENGL_HAS_OSMESA)
#-----------------------------------------------------------------------------
# EGL variables
#-----------------------------------------------------------------------------
# OpenGL implementation supports EGL for creating offscreen context.
set(default_has_egl OFF)
if(DEFINED VTK_USE_OFFSCREEN_EGL)
message(DEPRECATION "`VTK_USE_OFFSCREEN_EGL` cache variable is replaced by "
"`VTK_OPENGL_HAS_EGL`. Plase use it instead. The new name "
"better reflects the variable's purpose.")
set(default_has_egl ${VTK_USE_OFFSCREEN_EGL})
endif()
# EGL offscreen rendering option(VTK_OPENGL_HAS_EGL "The OpenGL library being used supports EGL" ${default_has_egl})
option(VTK_USE_OFFSCREEN_EGL mark_as_advanced(VTK_OPENGL_HAS_EGL)
"Use EGL for OpenGL client API for offscreen rendering." OFF)
set(default_egl_device_index 0)
if(DEFINED VTK_EGL_DEVICE_INDEX)
message(DEPRECATION "`VTK_EGL_DEVICE_INDEX` cache variable is replaced by "
"`VTK_DEFAULT_EGL_DEVICE_INDEX`. Please use it instead. The new name "
"better reflects the variable's purpose.")
set(default_egl_device_index ${VTK_EGL_DEVICE_INDEX})
endif()
set(VTK_EGL_DEVICE_INDEX 0 CACHE STRING set(VTK_DEFAULT_EGL_DEVICE_INDEX "${default_egl_device_index}" CACHE STRING
"Index of the EGL device (graphics card) to use.") "EGL device (graphics card) index to use by default for EGL render windows.")
mark_as_advanced(VTK_DEFAULT_EGL_DEVICE_INDEX)
if (VTK_USE_OFFSCREEN_EGL AND VTK_RENDERING_BACKEND STREQUAL "OpenGL") # Some sanity checks for use of EGL.
message(FATAL_ERROR "You can use VTK_USE_OFFSCREEN_EGL only for OpenGL2") if (VTK_OPENGL_HAS_EGL AND VTK_RENDERING_BACKEND STREQUAL "OpenGL")
message(FATAL_ERROR "You can use VTK_OPENGL_HAS_EGL only for `OpenGL2` rendering backend")
endif() endif()
if (VTK_USE_OFFSCREEN_EGL AND ANDROID) if (VTK_OPENGL_HAS_EGL AND ANDROID)
message(FATAL_ERROR "You cannot use VTK_USE_OFFSCREEN_EGL on the ANDROID platform") message(FATAL_ERROR "You cannot use VTK_OPENGL_HAS_EGL on the ANDROID platform")
endif() endif()
option(VTK_USE_OFFSCREEN "Use off screen calls by default" OFF) #-----------------------------------------------------------------------------
# Irrespective of support for offscreen API, VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN
# lets the user select the default state for the `Offscreen` flag on the
# vtkRenderWindow when it is instantiated (formerly VTK_USE_OFFSCREEN).
set(default_use_offscreen OFF)
if(DEFINED VTK_USE_OFFSCREEN)
message(DEPRECATION "`VTK_USE_OFFSCREEN` cache variable is replaced by "
"`VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN`. Please use it instead. The new name "
"better reflects the variable's purpose.")
set(default_use_offscreen ${VTK_USE_OFFSCREEN})
endif()
option(VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN "Use offscreen calls by default" ${default_use_offscreen})
mark_as_advanced(VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
unset(VTK_CAN_DO_OFFSCREEN) #-----------------------------------------------------------------------------
unset(VTK_CAN_DO_ONSCREEN) set(VTK_CAN_DO_OFFSCREEN FALSE)
set(VTK_CAN_DO_ONSCREEN FALSE)
if(VTK_OPENGL_HAS_OSMESA OR WIN32 OR VTK_USE_OFFSCREEN_EGL) if(WIN32 OR VTK_OPENGL_HAS_OSMESA OR VTK_OPENGL_HAS_EGL)
set(VTK_CAN_DO_OFFSCREEN 1) set(VTK_CAN_DO_OFFSCREEN TRUE)
endif() endif()
if(WIN32 OR VTK_USE_COCOA OR VTK_USE_X)
if(VTK_USE_X OR VTK_USE_COCOA OR WIN32 OR ANDROID OR APPLE_IOS) set(VTK_CAN_DO_ONSCREEN TRUE)
set(VTK_USE_OSMESA ${VTK_OPENGL_HAS_OSMESA})
if (VTK_USE_OFFSCREEN_EGL)
message(FATAL_ERROR "VTK_USE_OFFSCREEN_EGL set together with one of ("
"VTK_USE_X, VTK_USE_COCOA, WIN32, ANDROID OR APPLE_IOS). "
"You cannot use both offscreen and one of the listed windowing systems.")
endif()
set(VTK_CAN_DO_ONSCREEN 1)
elseif(VTK_USE_OFFSCREEN_EGL)
set(VTK_USE_OSMESA FALSE)
else()
set(VTK_USE_OSMESA ${VTK_OPENGL_HAS_OSMESA})
endif() endif()
mark_as_advanced(VTK_USE_X VTK_OPENGL_HAS_OSMESA VTK_USE_OFFSCREEN_EGL #-----------------------------------------------------------------------------
VTK_USE_OFFSCREEN VTK_EGL_DEVICE_INDEX) # The following assumes shared dispatch between onscreen and offscreen GL
# implementations.
if(VTK_USE_OSMESA) if(VTK_OPENGL_HAS_OSMESA)
find_package(OSMesa REQUIRED) find_package(OSMesa REQUIRED)
include_directories(SYSTEM ${OSMESA_INCLUDE_DIR}) include_directories(SYSTEM ${OSMESA_INCLUDE_DIR})
endif() endif()
if(VTK_USE_OFFSCREEN_EGL) if(VTK_OPENGL_HAS_EGL)
find_package(EGL REQUIRED) find_package(EGL REQUIRED)
include_directories(SYSTEM ${EGL_INCLUDE_DIR})
endif() endif()
if(VTK_CAN_DO_ONSCREEN) if(VTK_CAN_DO_ONSCREEN)
...@@ -95,11 +128,11 @@ endif() ...@@ -95,11 +128,11 @@ endif()
# Function to link a VTK target to the necessary OpenGL libraries. # Function to link a VTK target to the necessary OpenGL libraries.
function(vtk_opengl_link target) function(vtk_opengl_link target)
if(VTK_USE_OSMESA) if(VTK_OPENGL_HAS_OSMESA)
vtk_module_link_libraries(${target} LINK_PRIVATE ${OSMESA_LIBRARY}) vtk_module_link_libraries(${target} LINK_PRIVATE ${OSMESA_LIBRARY})
endif() endif()
if(VTK_USE_OFFSCREEN_EGL) if(VTK_OPENGL_HAS_EGL)
vtk_module_link_libraries(${target} LINK_PRIVATE ${EGL_LIBRARIES}) vtk_module_link_libraries(${target} LINK_PRIVATE EGL::EGL)
endif() endif()
if(VTK_CAN_DO_ONSCREEN) if(VTK_CAN_DO_ONSCREEN)
vtk_module_link_libraries(${target} LINK_PRIVATE ${OPENGL_LIBRARIES}) vtk_module_link_libraries(${target} LINK_PRIVATE ${OPENGL_LIBRARIES})
......
if(NOT VTK_OPENGL_HAS_OSMESA AND NOT VTK_USE_OFFSCREEN_EGL) include(vtkOpenGL)
if(VTK_CAN_DO_ONSCREEN AND NOT VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
vtk_add_test_python( vtk_add_test_python(
TestFlyTo.py TestFlyTo.py
TestStyleRubberBandZoom.py TestStyleRubberBandZoom.py
......
if(NOT VTK_OPENGL_HAS_OSMESA AND NOT VTK_USE_OFFSCREEN_EGL) include(vtkOpenGL)
if(VTK_CAN_DO_ONSCREEN AND NOT VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
vtk_add_test_python( vtk_add_test_python(
TestImagePlaneWidget.py TestImagePlaneWidget.py
TestBoxWidget.py,NO_RT TestBoxWidget.py,NO_RT
......
...@@ -216,6 +216,6 @@ endif() ...@@ -216,6 +216,6 @@ endif()
vtk_module_library(vtkRenderingCore ${Module_SRCS}) vtk_module_library(vtkRenderingCore ${Module_SRCS})
if (VTK_USE_OFFSCREEN) if (VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
target_compile_definitions(vtkRenderingCore PRIVATE -DVTK_USE_OFFSCREEN) target_compile_definitions(vtkRenderingCore PRIVATE -DVTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
endif() endif()
...@@ -27,7 +27,7 @@ else() ...@@ -27,7 +27,7 @@ else()
) )
endif() endif()
if (VTK_USE_OFFSCREEN) if (VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
list(APPEND extra_opengl2_tests TestOffscreenIsOffscreen.cxx,NO_DATA,NO_VALID) list(APPEND extra_opengl2_tests TestOffscreenIsOffscreen.cxx,NO_DATA,NO_VALID)
endif() endif()
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
int TestOffscreenIsOffscreen(int, char* []) int TestOffscreenIsOffscreen(int, char* [])
{ {
vtkNew<vtkRenderWindow> renWin; vtkNew<vtkRenderWindow> renWin;
// This test is only run if VTK_USE_OFFSCREEN is on. So the default should // This test is only run if VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN is on. So the default should
// be to use offscreen rendering // be to use offscreen rendering
return !renWin->GetOffScreenRendering(); return !renWin->GetOffScreenRendering();
} }
...@@ -64,7 +64,7 @@ const char *vtkGraphicsFactory::GetRenderLibrary() ...@@ -64,7 +64,7 @@ const char *vtkGraphicsFactory::GetRenderLibrary()
// if nothing is set then work down the list of possible renderers // if nothing is set then work down the list of possible renderers
if ( !temp ) if ( !temp )
{ {
#if defined(VTK_DISPLAY_X11_OGL) || defined(VTK_USE_OSMESA) #if defined(VTK_DISPLAY_X11_OGL) || defined(VTK_OPENGL_HAS_OSMESA)
temp = "OpenGL"; temp = "OpenGL";
#endif #endif
#ifdef VTK_DISPLAY_WIN32_OGL #ifdef VTK_DISPLAY_WIN32_OGL
......
...@@ -91,7 +91,7 @@ vtkRenderWindow::vtkRenderWindow() ...@@ -91,7 +91,7 @@ vtkRenderWindow::vtkRenderWindow()
this->MultiSamples = 0; this->MultiSamples = 0;
this->UseSRGBColorSpace = false; this->UseSRGBColorSpace = false;
#ifdef VTK_USE_OFFSCREEN #ifdef VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN
this->OffScreenRendering = 1; this->OffScreenRendering = 1;
#endif #endif
this->DeviceIndex = 0; this->DeviceIndex = 0;
......
...@@ -175,7 +175,7 @@ if(WIN32) ...@@ -175,7 +175,7 @@ if(WIN32)
if(DirectX_FOUND) if(DirectX_FOUND)
set(VTK_USE_DIRECTX 1) set(VTK_USE_DIRECTX 1)
endif() endif()
elseif(APPLE AND NOT VTK_USE_OSMESA) elseif(APPLE AND NOT VTK_OPENGL_HAS_OSMESA)
set(VTK_USE_APPLE_LOADER 1) set(VTK_USE_APPLE_LOADER 1)
set(VTK_USE_CORE_GRAPHICS 1) set(VTK_USE_CORE_GRAPHICS 1)
else() else()
...@@ -228,7 +228,7 @@ else() ...@@ -228,7 +228,7 @@ else()
if(NVCtrlLib_FOUND) if(NVCtrlLib_FOUND)
set(VTK_USE_NVCONTROL 1) set(VTK_USE_NVCONTROL 1)
endif() endif()
elseif (VTK_USE_OSMESA) elseif (VTK_OPENGL_HAS_OSMESA)
# we'll use OSMesa to load extensions. # we'll use OSMesa to load extensions.
else() else()
set(VTK_NO_EXTENSION_LOADING 1) set(VTK_NO_EXTENSION_LOADING 1)
...@@ -329,7 +329,7 @@ if(VTK_USE_X) ...@@ -329,7 +329,7 @@ if(VTK_USE_X)
vtkXRenderWindowInteractor.cxx vtkXRenderWindowInteractor.cxx
vtkXOpenGLRenderWindow.cxx vtkXOpenGLRenderWindow.cxx
) )
elseif(VTK_USE_OSMESA) elseif(VTK_OPENGL_HAS_OSMESA)
list(APPEND vtk_module_overrides "vtkRenderWindow") list(APPEND vtk_module_overrides "vtkRenderWindow")
set(vtk_module_vtkRenderWindow_override "vtkOSOpenGLRenderWindow") set(vtk_module_vtkRenderWindow_override "vtkOSOpenGLRenderWindow")
list(APPEND Module_SRCS vtkOSOpenGLRenderWindow.cxx) list(APPEND Module_SRCS vtkOSOpenGLRenderWindow.cxx)
...@@ -411,7 +411,7 @@ set(${vtk-module}_EXPORT_CODE "#include \"vtkRenderingOpenGLConfigure.h\"") ...@@ -411,7 +411,7 @@ set(${vtk-module}_EXPORT_CODE "#include \"vtkRenderingOpenGLConfigure.h\"")
# Since several headers in this module include vtkOpenGL.h which needed GL.h, # Since several headers in this module include vtkOpenGL.h which needed GL.h,
# need to ensure that any dependent modules inherit the include directory # need to ensure that any dependent modules inherit the include directory
# automatically. # automatically.
if(VTK_USE_OSMESA) if(VTK_OPENGL_HAS_OSMESA)
set(${vtk-module}_SYSTEM_INCLUDE_DIRS set(${vtk-module}_SYSTEM_INCLUDE_DIRS
${OSMESA_INCLUDE_DIR}) ${OSMESA_INCLUDE_DIR})
else() else()
......
...@@ -99,7 +99,7 @@ foreach(exe ...@@ -99,7 +99,7 @@ foreach(exe
vtk_opengl_link(${exe}) vtk_opengl_link(${exe})
target_link_libraries(${exe} LINK_PRIVATE target_link_libraries(${exe} LINK_PRIVATE
${${vtk-module-test}-Cxx_LIBRARIES}) ${${vtk-module-test}-Cxx_LIBRARIES})
if(APPLE AND NOT VTK_USE_OSMESA) if(APPLE AND NOT VTK_OPENGL_HAS_OSMESA)
target_link_libraries(${exe} LINK_PRIVATE "-framework GLUT") target_link_libraries(${exe} LINK_PRIVATE "-framework GLUT")
endif() endif()
endforeach() endforeach()
......
...@@ -22,7 +22,7 @@ PURPOSE. See the above copyright notice for more information. ...@@ -22,7 +22,7 @@ PURPOSE. See the above copyright notice for more information.
#include <GL/gl.h> #include <GL/gl.h>
#include "vtkgl.h" #include "vtkgl.h"
#ifdef VTK_USE_OSMESA #ifdef VTK_OPENGL_HAS_OSMESA
# ifndef GLAPI # ifndef GLAPI
# define GLAPI extern # define GLAPI extern
...@@ -37,7 +37,7 @@ PURPOSE. See the above copyright notice for more information. ...@@ -37,7 +37,7 @@ PURPOSE. See the above copyright notice for more information.
# endif # endif
# include <GL/osmesa.h> # include <GL/osmesa.h>
#endif // VTK_USE_OSMESA #endif // VTK_OPENGL_HAS_OSMESA
#include "vtkCommand.h" #include "vtkCommand.h"
#include "vtkIdList.h" #include "vtkIdList.h"
......
...@@ -47,7 +47,7 @@ extern "C" vtkglX::__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *); ...@@ -47,7 +47,7 @@ extern "C" vtkglX::__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *);
#include <dlfcn.h> #include <dlfcn.h>
#endif //VTK_USE_APPLE_LOADER #endif //VTK_USE_APPLE_LOADER
#ifdef VTK_USE_OSMESA #ifdef VTK_OPENGL_HAS_OSMESA
# ifndef GLAPI # ifndef GLAPI
# define GLAPI extern # define GLAPI extern
...@@ -62,7 +62,7 @@ extern "C" vtkglX::__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *); ...@@ -62,7 +62,7 @@ extern "C" vtkglX::__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *);
# endif # endif
# include <GL/osmesa.h> # include <GL/osmesa.h>
#endif // VTK_USE_OSMESA #endif // VTK_OPENGL_HAS_OSMESA
// GLU is currently not linked in VTK. We do not support it here. // GLU is currently not linked in VTK. We do not support it here.
#define GLU_SUPPORTED 0 #define GLU_SUPPORTED 0
...@@ -733,7 +733,7 @@ vtkOpenGLExtensionManager::GetProcAddress(const char *fname) ...@@ -733,7 +733,7 @@ vtkOpenGLExtensionManager::GetProcAddress(const char *fname)
return NULL; return NULL;
#endif //VTK_USE_VTK_DYNAMIC_LOADER #endif //VTK_USE_VTK_DYNAMIC_LOADER
#ifdef VTK_USE_OSMESA #ifdef VTK_OPENGL_HAS_OSMESA
return static_cast<vtkOpenGLExtensionManagerFunctionPointer>( return static_cast<vtkOpenGLExtensionManagerFunctionPointer>(
OSMesaGetProcAddress(fname)); OSMesaGetProcAddress(fname));
#endif #endif
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#cmakedefine VTK_USE_GLX_GET_PROC_ADDRESS_ARB #cmakedefine VTK_USE_GLX_GET_PROC_ADDRESS_ARB
#cmakedefine VTK_USE_VTK_DYNAMIC_LOADER #cmakedefine VTK_USE_VTK_DYNAMIC_LOADER
#cmakedefine VTK_NO_EXTENSION_LOADING #cmakedefine VTK_NO_EXTENSION_LOADING
#cmakedefine VTK_USE_OSMESA #cmakedefine VTK_OPENGL_HAS_OSMESA
#cmakedefine VTK_DEFINE_GLX_GET_PROC_ADDRESS_PROTOTYPE #cmakedefine VTK_DEFINE_GLX_GET_PROC_ADDRESS_PROTOTYPE
......
...@@ -29,8 +29,18 @@ ...@@ -29,8 +29,18 @@
/* Rendering Configuration */ /* Rendering Configuration */
#cmakedefine VTK_USE_X #cmakedefine VTK_USE_X
#define VTK_USE_OPENGL_LIBRARY #define VTK_USE_OPENGL_LIBRARY
#cmakedefine VTK_USE_OSMESA #cmakedefine VTK_OPENGL_HAS_OSMESA
#cmakedefine VTK_USE_OFFSCREEN #cmakedefine VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN
// for legacy codes.
#ifdef VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN
# define VTK_USE_OFFSCREEN
#endif
// for legacy codes.
#ifdef VTK_OPENGL_HAS_OSMESA
# define VTK_USE_OSMESA
#endif
#cmakedefine VTK_USE_GLSL_SHADERS #cmakedefine VTK_USE_GLSL_SHADERS
......
...@@ -41,7 +41,7 @@ typedef ptrdiff_t GLsizeiptr; ...@@ -41,7 +41,7 @@ typedef ptrdiff_t GLsizeiptr;
#include "vtkToolkits.h" #include "vtkToolkits.h"
#ifdef VTK_USE_OSMESA #ifdef VTK_OPENGL_HAS_OSMESA