Commit cf406e96 authored by Marcus D. Hanwell's avatar Marcus D. Hanwell

Added a concept of backends, added OpenGL and OpenGL2

This adds a concept of a rendering backend to the module API, with
an OpenGL and OpenGL2 backend. They are mutually exclusive and one
or the other should be selected (or None in the case when rendering
is not requested). This needs a little more work as the default
backend enables rendering when the group is disabled at this point.

Change-Id: I98d660e063ef58d52698e08ab06dd45601bea9cd
parent c733e72a
# Default code to handle VTK backends. The module.cmake files specify
# which backend the modules are in. We can specify some more specific
# documentation for backends in this file that will be displayed in
# cmake-gui and ccmake.
#
# The OpenGL backend is the current default, and the OpenGL2 backend is
# the new rendering code. This differs from groups in that only one backend
# can be built/linked to at any given time. The backend modules should use a
# naming convention where the backend name is the final word in the
# module name, i.e. vtkRenderingOpenGL for OpenGL and vtkRenderingOpenGL2
# for OpenGL2.
# Set a default backend type if none was specified, populate the enum.
if(NOT VTK_RENDERING_BACKEND)
message(STATUS "Setting rendering backend to 'OpenGL' as none was specified.")
set(VTK_RENDERING_BACKEND "OpenGL" CACHE STRING
"Choose the rendering backend." FORCE)
# Set the possible values of rendering backends for cmake-gui
set_property(CACHE VTK_RENDERING_BACKEND PROPERTY
STRINGS ${VTK_BACKENDS} "None")
endif()
# Now iterate through and enable the one that was selected.
foreach(backend ${VTK_BACKENDS})
message(STATUS "Backend ${backend} modules: ${VTK_BACKEND_${backend}_MODULES}")
if(${backend} STREQUAL "${VTK_RENDERING_BACKEND}")
message(STATUS "Enabling modules for ${backend}.")
foreach(module ${VTK_BACKEND_${backend}_MODULES})
list(APPEND ${module}_REQUEST_BY VTK_BACKEND_${backend})
endforeach()
else()
message(STATUS "Disabling modules for ${backend}.")
endif()
endforeach()
......@@ -26,6 +26,8 @@ endif()
# DESCRIPTION = Free text description of the module
# TCL_NAME = Alternative name for the TCL wrapping (cannot contain numbers)
# IMPLEMENTS = Modules that this module implements, using the auto init feature
# BACKEND = An implementation backend that this module belongs (valid with
# IMPLEMENTS only)
# GROUPS = Module groups this module should be included in
# TEST_LABELS = Add labels to the tests for the module
#
......@@ -48,6 +50,7 @@ macro(vtk_module _name)
set(${vtk-module}_PRIVATE_DEPENDS "")
set(${vtk-module-test}_DEPENDS "${vtk-module}")
set(${vtk-module}_IMPLEMENTS "")
set(${vtk-module}_BACKEND "")
set(${vtk-module}_DESCRIPTION "description")
set(${vtk-module}_TCL_NAME "${vtk-module}")
set(${vtk-module}_EXCLUDE_FROM_ALL 0)
......@@ -55,7 +58,7 @@ macro(vtk_module _name)
set(${vtk-module}_EXCLUDE_FROM_WRAP_HIERARCHY 0)
set(${vtk-module}_TEST_LABELS "")
foreach(arg ${ARGN})
if("${arg}" MATCHES "^((|COMPILE_|PRIVATE_|TEST_|)DEPENDS|DESCRIPTION|TCL_NAME|IMPLEMENTS|DEFAULT|GROUPS|TEST_LABELS)$")
if("${arg}" MATCHES "^((|COMPILE_|PRIVATE_|TEST_|)DEPENDS|DESCRIPTION|TCL_NAME|IMPLEMENTS|BACKEND|DEFAULT|GROUPS|TEST_LABELS)$")
set(_doing "${arg}")
elseif("${arg}" MATCHES "^EXCLUDE_FROM_ALL$")
set(_doing "")
......@@ -92,6 +95,15 @@ macro(vtk_module _name)
elseif("${_doing}" MATCHES "^IMPLEMENTS$")
list(APPEND ${vtk-module}_DEPENDS "${arg}")
list(APPEND ${vtk-module}_IMPLEMENTS "${arg}")
elseif("${_doing}" MATCHES "^BACKEND$")
# Backends control groups of implementation modules, a module may be in
# multiple groups, and it should be an implementation of an interface
# module. The current BACKENDS are OpenGL and OpenGL2 (new rendering).
if(NOT DEFINED VTK_BACKEND_${arg}_MODULES)
list(APPEND VTK_BACKENDS ${arg})
endif()
list(APPEND VTK_BACKEND_${arg}_MODULES ${vtk-module})
list(APPEND ${vtk-module}_BACKEND "${arg}")
elseif("${_doing}" MATCHES "^DEFAULT")
message(FATAL_ERROR "Invalid argument [DEFAULT]")
elseif("${_doing}" MATCHES "^GROUPS")
......
......@@ -24,12 +24,29 @@ if (module_files)
file(REMOVE ${module_files})
endif()
# This is a little hackish, but define the rendering backend if none was passed
# in for the first CMake invocation for modules that depend on the backend
# chosen.
if(NOT DEFINED VTK_RENDERING_BACKEND)
set(VTK_RENDERING_BACKEND "OpenGL")
set(_backend_set_for_first_cmake TRUE)
endif()
# Assess modules, and tests in the repository.
vtk_module_search(${_test_languages})
# Need to ensure the state is restored so that cache variable defaults can be
# added if necessary on the first CMake run, offering up the choice of backend.
if(_backend_set_for_first_cmake)
unset(VTK_RENDERING_BACKEND)
endif()
# Now include the module group logic.
include(vtkGroups)
# Now figure out which rendering backend to use.
include(vtkBackends)
# Validate the module DAG.
macro(vtk_module_check vtk-module _needed_by stack)
if(NOT ${vtk-module}_DECLARED)
......
......@@ -275,15 +275,6 @@ SET(VTK_HAS_EXODUS 1)
# Provide a few configuration options.
OPTION(BUILD_EXAMPLES "Build VTK examples." OFF)
#-----------------------------------------------------------------------------
# Use the OpenGL2 versions of classes
option(VTK_REPLACE_OPENGL_OVERRIDES
"Replace OpenGL overrides with experimental OpenGL2 overrides (experimental"
ON)
if (VTK_REPLACE_OPENGL_OVERRIDES)
set(Module_vtkRenderingOpenGL2 ON CACHE BOOL "Always build OpenGL2 classes for this branch" FORCE)
endif()
#-----------------------------------------------------------------------------
# Configure files with settings for use by the build.
......
......@@ -4,7 +4,7 @@ vtk_module(vtkCommonColor
TEST_DEPENDS
vtkIOImage
vtkCommonExecutionModel
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingCore
vtkTestingRendering
vtkInteractionStyle
......
......@@ -15,6 +15,5 @@ vtk_module(vtkCommonDataModel
vtkIOGeometry
vtkIOLegacy
vtkIOXML
vtkRenderingCore
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
)
......@@ -11,5 +11,5 @@ vtk_module(vtkDomainsChemistry
vtkTestingCore
vtkTestingRendering
vtkInteractionStyle
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
)
......@@ -14,5 +14,5 @@ vtk_module(vtkFiltersCore
vtkIOXML
vtkImagingCore
vtkFiltersGeneral
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
)
......@@ -10,7 +10,7 @@ vtk_module(vtkFiltersExtraction
TEST_DEPENDS
vtkIOLegacy
vtkIOXML
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingRendering
vtkInteractionStyle
)
......@@ -12,5 +12,5 @@ vtk_module(vtkFiltersFlowPaths
vtkTestingCore
vtkTestingRendering
vtkInteractionStyle
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
)
......@@ -9,7 +9,7 @@ vtk_module(vtkFiltersGeneral
vtkIOXML
vtkImagingMath
vtkInteractionStyle
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingFreeTypeOpenGL
vtkRenderingAnnotation
vtkRenderingLabel
......
......@@ -7,7 +7,7 @@ vtk_module(vtkFiltersGeneric
TEST_DEPENDS
vtkIOXML
vtkIOLegacy
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingFreeTypeOpenGL
vtkFiltersModeling
vtkRenderingLabel
......
......@@ -5,7 +5,7 @@ vtk_module(vtkFiltersGeometry
vtkFiltersCore
TEST_DEPENDS
vtkIOXML
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingRendering
vtkInteractionStyle
)
......@@ -7,7 +7,7 @@ vtk_module(vtkFiltersHybrid
vtkRenderingCore # For vtkCamera in vtkDepthSortPolyData
TEST_DEPENDS
vtkIOXML
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkImagingCore
vtkImagingStencil
vtkTestingRendering
......
......@@ -7,7 +7,7 @@ vtk_module(vtkFiltersModeling
TEST_DEPENDS
vtkCommonColor # For vtkBandedPolyDataContourFilter used in a test
vtkIOXML
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingRendering
vtkInteractionStyle
)
......@@ -12,7 +12,7 @@ vtk_module(vtkFiltersParallel
vtkTestingCore
vtkTestingRendering
vtkInteractionStyle
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingParallel
vtkFiltersParallelMPI
vtkFiltersParallelImaging
......
......@@ -4,7 +4,7 @@ vtk_module(vtkFiltersProgrammable
DEPENDS
vtkCommonExecutionModel
TEST_DEPENDS
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingRendering
vtkInteractionStyle
)
......@@ -2,7 +2,7 @@ vtk_module(vtkFiltersReebGraph
DEPENDS
vtkFiltersCore
TEST_DEPENDS
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingRendering
vtkInteractionStyle
)
......@@ -8,7 +8,7 @@ vtk_module(vtkFiltersSelection
vtkFiltersExtraction
vtkIOLegacy
vtkIOXML
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingFreeTypeOpenGL
vtkRenderingAnnotation
vtkTestingRendering
......
......@@ -8,7 +8,7 @@ vtk_module(vtkFiltersSources
vtkTestingCore
vtkTestingRendering
vtkInteractionStyle
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingFreeTypeOpenGL
vtkFiltersModeling
vtkIOXML
......
......@@ -3,7 +3,7 @@ if(WIN32)
vtk_module(vtkGUISupportMFC
GROUPS
DEPENDS
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkInteractionStyle
EXCLUDE_FROM_WRAPPING
)
......
......@@ -3,7 +3,7 @@ vtk_module(vtkGUISupportQt
Qt
DEPENDS
vtkCommonExecutionModel
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkInteractionStyle
vtkImagingCore
PRIVATE_DEPENDS
......
......@@ -3,7 +3,7 @@ vtk_module(vtkGUISupportQtOpenGL
Qt
DEPENDS
vtkGUISupportQt
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
TEST_DEPENDS
vtkTestingCore
EXCLUDE_FROM_WRAPPING
......
......@@ -8,6 +8,6 @@ vtk_module(vtkRenderingContext2D
vtkCommonDataModel
vtkCommonMath
vtkCommonTransforms
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingFreeType
)
......@@ -13,5 +13,5 @@ vtk_module(vtkRenderingCore
vtkIOXML
vtkTestingCore
vtkTestingRendering
vtkRenderingOpenGL2
vtkRendering${VTK_RENDERING_BACKEND}
)
vtk_module(vtkRenderingOpenGL
GROUPS
Rendering
IMPLEMENTS
vtkRenderingCore
BACKEND
OpenGL
PRIVATE_DEPENDS
# These are likely to be removed soon - split Rendering/OpenGL further.
vtkImagingHybrid # For vtkSampleFunction
......
......@@ -3,6 +3,8 @@ vtk_module(vtkRenderingOpenGL2
vtkCommonExecutionModel
IMPLEMENTS
vtkRenderingCore
BACKEND
OpenGL2
PRIVATE_DEPENDS
vtksys
COMPILE_DEPENDS
......
vtk_module(vtkRenderingVolumeOpenGL
GROUPS
Rendering
IMPLEMENTS
vtkRenderingVolume
BACKEND
OpenGL
DEPENDS
vtkRenderingOpenGL
PRIVATE_DEPENDS
......
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