Skip to content

Commit d0efc67

Browse files
committed
Add CMake variable and C++ macro VTK_RENDERING_BACKEND_OPENGL_VERSION
These can be used at configuration and compilation times to adjust for the currently used backend.
1 parent 9cfb009 commit d0efc67

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CMakeLists.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,12 @@ option(WITH_VTK "Build VTK-Visualizations" TRUE)
361361
if(WITH_VTK AND NOT ANDROID)
362362
find_package(VTK)
363363
if(VTK_FOUND)
364-
message(STATUS "VTK_MAJOR_VERSION ${VTK_MAJOR_VERSION}")
364+
if(NOT DEFINED VTK_RENDERING_BACKEND)
365+
# On old VTK versions this variable does not exist. In this case it is
366+
# safe to assume OpenGL backend
367+
set(VTK_RENDERING_BACKEND "OpenGL")
368+
endif()
369+
message(STATUS "VTK_MAJOR_VERSION ${VTK_MAJOR_VERSION}, rendering backend: ${VTK_RENDERING_BACKEND}")
365370
if (PCL_SHARED_LIBS OR
366371
(NOT (PCL_SHARED_LIBS) AND NOT (VTK_BUILD_SHARED_LIBS)))
367372
set(VTK_FOUND TRUE)
@@ -377,6 +382,11 @@ if(WITH_VTK AND NOT ANDROID)
377382
option (VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
378383
MARK_AS_ADVANCED (VTK_USE_COCOA)
379384
endif (APPLE)
385+
if(${VTK_RENDERING_BACKEND} STREQUAL "OpenGL")
386+
set(VTK_RENDERING_BACKEND_OPENGL_VERSION "1")
387+
elseif(${VTK_RENDERING_BACKEND} STREQUAL "OpenGL2")
388+
set(VTK_RENDERING_BACKEND_OPENGL_VERSION "2")
389+
endif()
380390
set(HAVE_VTK ON)
381391
else ()
382392
set(VTK_FOUND OFF)

pcl_config.h.in

+4
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,7 @@
7171
/* Address the cases where on MacOS and OpenGL and GLUT are not frameworks */
7272
#cmakedefine OPENGL_IS_A_FRAMEWORK
7373
#cmakedefine GLUT_IS_A_FRAMEWORK
74+
75+
/* Version of OpenGL used by VTK as rendering backend */
76+
#define VTK_RENDERING_BACKEND_OPENGL_VERSION ${VTK_RENDERING_BACKEND_OPENGL_VERSION}
77+

0 commit comments

Comments
 (0)