Commit ae464766 authored by mark's avatar mark
Browse files

COMP: patch paraview 5.0.1 for building with osmesa

- reference: https://gitlab.kitware.com/vtk/vtk/merge_requests/1642
parent 45caecb8
......@@ -85,3 +85,137 @@
set (xslt_xml)
--- ParaView-5.0.1/VTK/CMake/vtkOpenGL.cmake.orig 2016-03-28 17:07:10.000000000 +0200
+++ ParaView-5.0.1/VTK/CMake/vtkOpenGL.cmake 2017-01-19 10:23:19.170743269 +0100
@@ -19,9 +19,11 @@
# OSMesa logic for offscreen mesa rendering.
option(VTK_OPENGL_HAS_OSMESA
"The OpenGL library being used supports off screen Mesa calls" OFF)
+
# EGL offscreen rendering
option(VTK_USE_OFFSCREEN_EGL
"Use EGL for OpenGL client API for offscreen rendering." OFF)
+
set(VTK_EGL_DEVICE_INDEX 0 CACHE STRING
"Index of the EGL device (graphics card) to use.")
@@ -33,21 +35,26 @@
endif()
option(VTK_USE_OFFSCREEN "Use off screen calls by default" OFF)
+
unset(VTK_CAN_DO_OFFSCREEN)
+unset(VTK_CAN_DO_ONSCREEN)
+
if(VTK_OPENGL_HAS_OSMESA OR WIN32 OR VTK_USE_OFFSCREEN_EGL)
set(VTK_CAN_DO_OFFSCREEN 1)
endif()
+
if(VTK_USE_X OR VTK_USE_COCOA OR WIN32 OR ANDROID OR APPLE_IOS)
- set(VTK_USE_OSMESA FALSE)
+ 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 TRUE)
+ set(VTK_USE_OSMESA ${VTK_OPENGL_HAS_OSMESA})
endif()
mark_as_advanced(VTK_USE_X VTK_OPENGL_HAS_OSMESA VTK_USE_OFFSCREEN_EGL
@@ -56,10 +63,17 @@
if(VTK_USE_OSMESA)
find_package(OSMesa REQUIRED)
include_directories(SYSTEM ${OSMESA_INCLUDE_DIR})
-elseif(VTK_USE_OFFSCREEN_EGL)
+endif()
+
+if(VTK_USE_OFFSCREEN_EGL)
find_package(EGL REQUIRED)
include_directories(SYSTEM ${EGL_INCLUDE_DIR})
-else()
+endif()
+
+if(VTK_CAN_DO_ONSCREEN)
+ # OpenGL libraries are explicity needed if windowing system-based API is being
+ # used. Otherwise, if only doing OFFSCREEN, the GL API is provided by the
+ # offscreen library be it EGL or OSMESA.
find_package(OpenGL REQUIRED)
include_directories(SYSTEM ${OPENGL_INCLUDE_DIR})
if(APPLE)
@@ -83,9 +97,11 @@
function(vtk_opengl_link target)
if(VTK_USE_OSMESA)
vtk_module_link_libraries(${target} LINK_PRIVATE ${OSMESA_LIBRARY})
- elseif(VTK_USE_OFFSCREEN_EGL)
+ endif()
+ if(VTK_USE_OFFSCREEN_EGL)
vtk_module_link_libraries(${target} LINK_PRIVATE ${EGL_LIBRARIES})
- else()
+ endif()
+ if(VTK_CAN_DO_ONSCREEN)
vtk_module_link_libraries(${target} LINK_PRIVATE ${OPENGL_LIBRARIES})
endif()
endfunction()
--- ParaView-5.0.1/VTK/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx.orig 2016-03-28 17:07:10.000000000 +0200
+++ ParaView-5.0.1/VTK/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx 2017-01-19 15:24:21.783214877 +0100
@@ -30,10 +30,25 @@
typedef ptrdiff_t GLsizeiptr;
#include "GL/glx.h"
+
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY GLAPIENTRY
+#endif
+
#include "vtkToolkits.h"
#ifdef VTK_USE_OSMESA
#include <GL/osmesa.h>
+
+typedef OSMesaContext GLAPIENTRY (*OSMesaCreateContextAttribs_func)( const int *attribList, OSMesaContext sharelist );
#endif
#include "vtkCommand.h"
@@ -757,6 +772,28 @@
this->Size[1] = height;
this->OwnWindow = 1;
}
+
+#if (OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 1102) && defined(OSMESA_CONTEXT_MAJOR_VERSION)
+ static const int attribs[] = {
+ OSMESA_FORMAT, OSMESA_RGBA,
+ OSMESA_DEPTH_BITS, 32,
+ OSMESA_STENCIL_BITS, 0,
+ OSMESA_ACCUM_BITS, 0,
+ OSMESA_PROFILE, OSMESA_CORE_PROFILE,
+ OSMESA_CONTEXT_MAJOR_VERSION, 3,
+ OSMESA_CONTEXT_MINOR_VERSION, 2,
+ 0 };
+
+ OSMesaCreateContextAttribs_func OSMesaCreateContextAttribs =
+ (OSMesaCreateContextAttribs_func)
+ OSMesaGetProcAddress("OSMesaCreateContextAttribs");
+
+ if (OSMesaCreateContextAttribs != NULL)
+ {
+ this->Internal->OffScreenContextId = OSMesaCreateContextAttribs(attribs, NULL);
+ }
+#endif
+ // if we still have no context fall back to the generic signature
if (!this->Internal->OffScreenContextId)
{
this->Internal->OffScreenContextId = OSMesaCreateContext(GL_RGBA, NULL);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment