Commit d0e7aab3 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

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`
...
parent edd75a97
# Try to find EGL library and include dir.
# Once done this will define
#.rst:
# FindEGL
# -------
#
# EGL_FOUND - true if EGL has been found
# EGL_INCLUDE_DIR - where the EGL/egl.h and KHR/khrplatform.h can be found
# EGL_LIBRARY - link this to use libEGL.so.1
# 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
if(NOT EGL_INCLUDE_DIR)
# If we have a root defined look there first
if(EGL_ROOT)
find_path(EGL_INCLUDE_DIR EGL/egl.h PATHS ${EGL_ROOT}/include
NO_DEFAULT_PATH
)
endif()
if(NOT EGL_INCLUDE_DIR)
find_path(EGL_INCLUDE_DIR EGL/egl.h PATHS
/usr/local/include
/usr/include
)
endif()
endif()
if(NOT EGL_LIBRARY)
# If we have a root defined look there first
if(EGL_ROOT)
find_library(EGL_LIBRARY EGL PATHS ${EGL_ROOT}/lib
NO_DEFAULT_PATH
)
endif()
# Find the EGL library.
#
# Imported Targets
# ^^^^^^^^^^^^^^^^
#
# This module defines the following :prop_tgt:`IMPORTED` targets:
#
# ``EGL::EGL``
# The EGL library, if found.
#
# ``EGL::OpenGL``
# The OpenGL library, if found.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
# ``EGL_FOUND``
# System has the EGL library.
# ``EGL_INCLUDE_DIR``
# The EGL include directory.
# ``EGL_LIBRARY``
# The libEGL library.
# ``EGL_LIBRARIES``
# All EGL related libraries, including ``EGL_LIBRARY``.
#
# Hints
# ^^^^^
#
# Set `EGL_ROOT_DIR` to the root directory of an EGL installation.
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 EGL PATHS
/usr/local/lib
/usr/lib
)
endif()
endif()
find_library(EGL_LIBRARY
NAMES
EGL
PATHS
${EGL_ROOT_DIR}/lib
/usr/local/lib
/usr/lib)
if(NOT EGL_opengl_LIBRARY)
# If we have a root defined look there first
if(EGL_ROOT)
find_library(EGL_opengl_LIBRARY OpenGL PATHS ${EGL_ROOT}/lib
NO_DEFAULT_PATH
)
endif()
find_library(EGL_opengl_LIBRARY
NAMES
OpenGL
PATHS
${EGL_ROOT_DIR}/lib
/usr/local/lib
/usr/lib)
if(NOT EGL_opengl_LIBRARY)
find_library(EGL_opengl_LIBRARY OpenGL PATHS
/usr/local/lib
/usr/lib
)
endif()
endif()
set(EGL_LIBRARIES ${EGL_LIBRARY} ${EGL_opengl_LIBRARY})
if(NOT EGL_gldispatch_LIBRARY)
# If we have a root defined look there first
if(EGL_ROOT)
find_library(EGL_gldispatch_LIBRARY GLdispatch PATHS ${EGL_ROOT}/lib
NO_DEFAULT_PATH
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
EGL DEFAULT_MSG
EGL_LIBRARY EGL_opengl_LIBRARY EGL_INCLUDE_DIR)
mark_as_advanced(EGL_ROOT_DIR EGL_INCLUDE_DIR EGL_LIBRARY EGL_opengl_LIBRARY)
if(NOT EGL_gldispatch_LIBRARY)
find_library(EGL_gldispatch_LIBRARY GLdispatch PATHS
/usr/local/lib
/usr/lib
)
endif()
if(EGL_FOUND)
add_library(EGL::OpenGL UNKNOWN IMPORTED)
set_target_properties(EGL::OpenGL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}")
set_target_properties(EGL::OpenGL PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${EGL_opengl_LIBRARY}")
# For the NVIDIA 358 drivers there isn't a libGLdispath.so. The
# proper one gets installed as libGLdispatch.so.0.
if(NOT EGL_gldispatch_LIBRARY)
find_library(EGL_gldispatch_LIBRARY libGLdispatch.so.0 PATHS
/usr/local/lib
/usr/lib
)
endif()
add_library(EGL::EGL UNKNOWN IMPORTED)
set_target_properties(EGL::EGL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${EGL_INCLUDE_DIR}")
set_target_properties(EGL::EGL PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
INTERFACE_LINK_LIBRARIES "EGL::OpenGL"
IMPORTED_LOCATION "${EGL_LIBRARY}")
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
# 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)
option(VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
mark_as_advanced(VTK_USE_COCOA)
......@@ -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.")
endif ()
elseif(UNIX AND NOT ANDROID AND NOT APPLE_IOS)
set(VTK_USE_X_DEFAULT ON)
set(default_use_x ON)
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
"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_USE_OFFSCREEN_EGL
"Use EGL for OpenGL client API for offscreen rendering." OFF)
option(VTK_OPENGL_HAS_EGL "The OpenGL library being used supports EGL" ${default_has_egl})
mark_as_advanced(VTK_OPENGL_HAS_EGL)
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
"Index of the EGL device (graphics card) to use.")
set(VTK_DEFAULT_EGL_DEVICE_INDEX "${default_egl_device_index}" CACHE STRING
"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")
message(FATAL_ERROR "You can use VTK_USE_OFFSCREEN_EGL only for OpenGL2")
# Some sanity checks for use of EGL.
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()
if (VTK_USE_OFFSCREEN_EGL AND ANDROID)
message(FATAL_ERROR "You cannot use VTK_USE_OFFSCREEN_EGL on the ANDROID platform")
if (VTK_OPENGL_HAS_EGL AND ANDROID)
message(FATAL_ERROR "You cannot use VTK_OPENGL_HAS_EGL on the ANDROID platform")
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)
set(VTK_CAN_DO_OFFSCREEN 1)
if(WIN32 OR VTK_OPENGL_HAS_OSMESA OR VTK_OPENGL_HAS_EGL)
set(VTK_CAN_DO_OFFSCREEN TRUE)
endif()
if(VTK_USE_X OR VTK_USE_COCOA OR WIN32 OR ANDROID OR APPLE_IOS)
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})
if(WIN32 OR VTK_USE_COCOA OR VTK_USE_X)
set(VTK_CAN_DO_ONSCREEN TRUE)
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)
include_directories(SYSTEM ${OSMESA_INCLUDE_DIR})
endif()
if(VTK_USE_OFFSCREEN_EGL)
if(VTK_OPENGL_HAS_EGL)
find_package(EGL REQUIRED)
include_directories(SYSTEM ${EGL_INCLUDE_DIR})
endif()
if(VTK_CAN_DO_ONSCREEN)
......@@ -95,11 +128,11 @@ endif()
# Function to link a VTK target to the necessary OpenGL libraries.
function(vtk_opengl_link target)
if(VTK_USE_OSMESA)
if(VTK_OPENGL_HAS_OSMESA)
vtk_module_link_libraries(${target} LINK_PRIVATE ${OSMESA_LIBRARY})
endif()
if(VTK_USE_OFFSCREEN_EGL)
vtk_module_link_libraries(${target} LINK_PRIVATE ${EGL_LIBRARIES})
if(VTK_OPENGL_HAS_EGL)
vtk_module_link_libraries(${target} LINK_PRIVATE EGL::EGL)
endif()
if(VTK_CAN_DO_ONSCREEN)
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(
TestFlyTo.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(
TestImagePlaneWidget.py
TestBoxWidget.py,NO_RT
......
......@@ -216,6 +216,6 @@ endif()
vtk_module_library(vtkRenderingCore ${Module_SRCS})
if (VTK_USE_OFFSCREEN)
target_compile_definitions(vtkRenderingCore PRIVATE -DVTK_USE_OFFSCREEN)
if (VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
target_compile_definitions(vtkRenderingCore PRIVATE -DVTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
endif()
......@@ -27,7 +27,7 @@ else()
)
endif()
if (VTK_USE_OFFSCREEN)
if (VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN)
list(APPEND extra_opengl2_tests TestOffscreenIsOffscreen.cxx,NO_DATA,NO_VALID)
endif()
......
......@@ -19,7 +19,7 @@
int TestOffscreenIsOffscreen(int, char* [])
{
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
return !renWin->GetOffScreenRendering();
}
......@@ -64,7 +64,7 @@ const char *vtkGraphicsFactory::GetRenderLibrary()
// if nothing is set then work down the list of possible renderers
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";
#endif
#ifdef VTK_DISPLAY_WIN32_OGL
......
......@@ -91,7 +91,7 @@ vtkRenderWindow::vtkRenderWindow()
this->MultiSamples = 0;
this->UseSRGBColorSpace = false;
#ifdef VTK_USE_OFFSCREEN
#ifdef VTK_DEFAULT_RENDER_WINDOW_OFFSCREEN
this->OffScreenRendering = 1;
#endif
this->DeviceIndex = 0;
......
......@@ -175,7 +175,7 @@ if(WIN32)
if(DirectX_FOUND)
set(VTK_USE_DIRECTX 1)
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_CORE_GRAPHICS 1)
else()
......@@ -228,7 +228,7 @@ else()
if(NVCtrlLib_FOUND)
set(VTK_USE_NVCONTROL 1)
endif()
elseif (VTK_USE_OSMESA)
elseif (VTK_OPENGL_HAS_OSMESA)
# we'll use OSMesa to load extensions.
else()
set(VTK_NO_EXTENSION_LOADING 1)
......@@ -329,7 +329,7 @@ if(VTK_USE_X)
vtkXRenderWindowInteractor.cxx
vtkXOpenGLRenderWindow.cxx
)
elseif(VTK_USE_OSMESA)
elseif(VTK_OPENGL_HAS_OSMESA)
list(APPEND vtk_module_overrides "vtkRenderWindow")
set(vtk_module_vtkRenderWindow_override "vtkOSOpenGLRenderWindow")
list(APPEND Module_SRCS vtkOSOpenGLRenderWindow.cxx)
......@@ -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,
# need to ensure that any dependent modules inherit the include directory
# automatically.
if(VTK_USE_OSMESA)
if(VTK_OPENGL_HAS_OSMESA)
set(${vtk-module}_SYSTEM_INCLUDE_DIRS
${OSMESA_INCLUDE_DIR})
else()
......
......@@ -99,7 +99,7 @@ foreach(exe
vtk_opengl_link(${exe})
target_link_libraries(${exe} LINK_PRIVATE
${${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")
endif()
endforeach()
......
......@@ -22,7 +22,7 @@ PURPOSE. See the above copyright notice for more information.
#include <GL/gl.h>
#include "vtkgl.h"
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
# ifndef GLAPI
# define GLAPI extern
......@@ -37,7 +37,7 @@ PURPOSE. See the above copyright notice for more information.
# endif
# include <GL/osmesa.h>
#endif // VTK_USE_OSMESA
#endif // VTK_OPENGL_HAS_OSMESA
#include "vtkCommand.h"
#include "vtkIdList.h"
......
......@@ -47,7 +47,7 @@ extern "C" vtkglX::__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *);
#include <dlfcn.h>
#endif //VTK_USE_APPLE_LOADER
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
# ifndef GLAPI
# define GLAPI extern
......@@ -62,7 +62,7 @@ extern "C" vtkglX::__GLXextFuncPtr glXGetProcAddressARB(const GLubyte *);
# endif
# 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.
#define GLU_SUPPORTED 0
......@@ -733,7 +733,7 @@ vtkOpenGLExtensionManager::GetProcAddress(const char *fname)
return NULL;
#endif //VTK_USE_VTK_DYNAMIC_LOADER
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
return static_cast<vtkOpenGLExtensionManagerFunctionPointer>(
OSMesaGetProcAddress(fname));
#endif
......
......@@ -28,7 +28,7 @@
#cmakedefine VTK_USE_GLX_GET_PROC_ADDRESS_ARB
#cmakedefine VTK_USE_VTK_DYNAMIC_LOADER
#cmakedefine VTK_NO_EXTENSION_LOADING
#cmakedefine VTK_USE_OSMESA
#cmakedefine VTK_OPENGL_HAS_OSMESA
#cmakedefine VTK_DEFINE_GLX_GET_PROC_ADDRESS_PROTOTYPE
......
......@@ -29,8 +29,18 @@
/* Rendering Configuration */
#cmakedefine VTK_USE_X
#define VTK_USE_OPENGL_LIBRARY
#cmakedefine VTK_USE_OSMESA
#cmakedefine VTK_USE_OFFSCREEN
#cmakedefine VTK_OPENGL_HAS_OSMESA
#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
......
......@@ -41,7 +41,7 @@ typedef ptrdiff_t GLsizeiptr;
#include "vtkToolkits.h"
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
# include <GL/osmesa.h>
#endif
......@@ -86,7 +86,7 @@ private:
int ScreenDoubleBuffer;
int ScreenMapped;
#if defined( VTK_USE_OSMESA )
#if defined( VTK_OPENGL_HAS_OSMESA )
// OffScreen stuff
OSMesaContext OffScreenContextId;
void *OffScreenWindow;
......@@ -108,7 +108,7 @@ vtkXOpenGLRenderWindowInternal::vtkXOpenGLRenderWindowInternal(
this->ScreenDoubleBuffer = rw->GetDoubleBuffer();
// OpenGL specific
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
this->OffScreenContextId = NULL;
this->OffScreenWindow = NULL;
#endif
......@@ -118,7 +118,7 @@ vtkStandardNewMacro(vtkXOpenGLRenderWindow);
#define MAX_LIGHTS 8
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
// a couple of routines for offscreen rendering
void vtkOSMesaDestroyWindow(void *Window)
{
......@@ -484,7 +484,7 @@ void vtkXOpenGLRenderWindow::SetStereoCapableWindow(int capable)
{
if (!this->Internal->ContextId && !this->Internal->PixmapContextId
&& !this->Internal->PbufferContextId
#if defined( VTK_USE_OSMESA )
#if defined( VTK_OPENGL_HAS_OSMESA )
&& !this->Internal->OffScreenContextId
#endif
)
......@@ -814,7 +814,7 @@ void vtkXOpenGLRenderWindow::CreateOffScreenWindow(int width, int height)
this->DoubleBuffer = 0;
// always prefer OSMESA if we built with it
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
if(1)
{
if (!this->Internal->OffScreenWindow)
......@@ -963,7 +963,7 @@ void vtkXOpenGLRenderWindow::DestroyOffScreenWindow()
}
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
if (this->Internal->OffScreenContextId)
{
OSMesaDestroyContext(this->Internal->OffScreenContextId);
......@@ -1009,7 +1009,7 @@ void vtkXOpenGLRenderWindow::ResizeOffScreenWindow(int width, int height)
// Generally, we simply destroy and recreate the offscreen window/contexts.
// However, that's totally unnecessary for OSMesa. So we avoid that.
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
if (this->Internal->OffScreenContextId && this->Internal->OffScreenWindow)
{
vtkOSMesaDestroyWindow(this->Internal->OffScreenWindow);
......@@ -1065,7 +1065,7 @@ void vtkXOpenGLRenderWindow::Initialize (void)
else if(this->OffScreenRendering &&
! (this->Internal->PixmapContextId ||
this->Internal->PbufferContextId
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
|| this->Internal->OffScreenContextId
#endif
|| this->OffScreenUseFrameBuffer
......@@ -1286,7 +1286,7 @@ void vtkXOpenGLRenderWindow::PrintSelf(ostream& os, vtkIndent indent)
this->Superclass::PrintSelf(os,indent);
os << indent << "ContextId: " << this->Internal->ContextId << "\n";
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
os << indent << "OffScreenContextId: " << this->Internal->OffScreenContextId << "\n";
#endif
os << indent << "Color Map: " << this->ColorMap << "\n";
......@@ -1314,7 +1314,7 @@ void vtkXOpenGLRenderWindow::MakeCurrent()
// XSynchronize(this->DisplayId,1);
// }
// XSetErrorHandler(vtkXError);
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
// set the current window
if (this->OffScreenRendering && this->Internal->OffScreenContextId)
......@@ -1369,7 +1369,7 @@ void vtkXOpenGLRenderWindow::MakeCurrent()
bool vtkXOpenGLRenderWindow::IsCurrent()
{
bool result=false;
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
if(this->OffScreenRendering && this->Internal->OffScreenContextId)
{
result=this->Internal->OffScreenContextId==OSMesaGetCurrentContext();
......@@ -1388,7 +1388,7 @@ bool vtkXOpenGLRenderWindow::IsCurrent()
result=this->Internal->ContextId==glXGetCurrentContext();
}
}
#ifdef VTK_USE_OSMESA
#ifdef VTK_OPENGL_HAS_OSMESA
}
#endif
return result;
......@@ -1421,7 +1421,7 @@ extern "C"
void *vtkXOpenGLRenderWindow::GetGenericContext()
{
#if defined(MESA) && defined(VTK_USE_OSMESA)
#if defined(MESA) &