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

Merge branch 'opengl2-rendering'

Change-Id: Ic20b72f27630033a76fceb6d3022074f6f6a5c5c
parents f34c15c9 8f5d490c
# - Try to find Eigen3 lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen3 3.1.2)
# to require version 3.1.2 or newer of Eigen3.
#
# Once done this will define
#
# EIGEN3_FOUND - system has eigen lib with correct version
# EIGEN3_INCLUDE_DIR - the eigen include directory
# EIGEN3_VERSION - eigen version
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
if(NOT Eigen3_FIND_VERSION)
if(NOT Eigen3_FIND_VERSION_MAJOR)
set(Eigen3_FIND_VERSION_MAJOR 2)
endif(NOT Eigen3_FIND_VERSION_MAJOR)
if(NOT Eigen3_FIND_VERSION_MINOR)
set(Eigen3_FIND_VERSION_MINOR 91)
endif(NOT Eigen3_FIND_VERSION_MINOR)
if(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION_PATCH 0)
endif(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
endif(NOT Eigen3_FIND_VERSION)
macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK FALSE)
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK TRUE)
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
if(NOT EIGEN3_VERSION_OK)
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
"but at least version ${Eigen3_FIND_VERSION} is required")
endif(NOT EIGEN3_VERSION_OK)
endmacro(_eigen3_check_version)
if (EIGEN3_INCLUDE_DIR)
# in cache already
_eigen3_check_version()
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
else (EIGEN3_INCLUDE_DIR)
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
PATHS
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES eigen3 eigen
)
if(EIGEN3_INCLUDE_DIR)
_eigen3_check_version()
endif(EIGEN3_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
mark_as_advanced(EIGEN3_INCLUDE_DIR)
endif(EIGEN3_INCLUDE_DIR)
# Find the GLEW library
#
# Defines:
#
# GLEW_FOUND - system has GLEW
# GLEW_INCLUDE_DIRS - the GLEW include directories
# GLEW_LIBRARY - The GLEW library
#
find_path(GLEW_INCLUDE_DIR GL/glew.h)
find_library(GLEW_LIBRARY NAMES GLEW glew32)
set(GLEW_INCLUDE_DIRS "${GLEW_INCLUDE_DIR}")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_INCLUDE_DIR GLEW_LIBRARY)
mark_as_advanced(GLEW_INCLUDE_DIR GLEW_LIBRARY)
# 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}_IMPLEMENTS}_IMPLEMENTATIONS ${module})
endforeach()
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,17 @@ 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}")
# Being a backend implicitly excludes from all (mutual exclusivity).
set(${vtk-module}_EXCLUDE_FROM_ALL 1)
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)
......@@ -95,6 +112,9 @@ macro(vtk_module_enable vtk-module _needed_by)
foreach(dep IN LISTS ${vtk-module}_DEPENDS)
vtk_module_enable(${dep} ${vtk-module})
endforeach()
foreach(imp IN LISTS ${vtk-module}_IMPLEMENTATIONS)
vtk_module_enable(${imp} ${vtk-module})
endforeach()
# If VTK_BUILD_ALL_MODULES_FOR_TESTS is true, then and then
# alone do we include the test modules in building build the dependency
......
......@@ -10,6 +10,7 @@ vtk_module(vtkChartsCore
vtkTestingCore
vtkTestingRendering
vtkViewsContext2D
vtkIOExport
vtkRenderingContext${VTK_RENDERING_BACKEND}
#vtkIOExport
vtkIOInfovis
)
......@@ -4,7 +4,7 @@ vtk_module(vtkCommonColor
TEST_DEPENDS
vtkIOImage
vtkCommonExecutionModel
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingCore
vtkTestingRendering
vtkInteractionStyle
......
......@@ -206,19 +206,19 @@ int vtkWin32OutputWindow::Initialize()
HWND win = CreateWindow(
L"vtkOutputWindow", L"vtkOutputWindow",
WS_OVERLAPPED | WS_CLIPCHILDREN,
0, 0, 512, 512,
0, 0, 800, 512,
NULL, NULL, GetModuleHandle(NULL), NULL);
#elif UNICODE
HWND win = CreateWindow(
L"vtkOutputWindow", L"vtkOutputWindow",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
0, 0, 512, 512,
0, 0, 800, 512,
NULL, NULL, GetModuleHandle(NULL), NULL);
#else
HWND win = CreateWindow(
"vtkOutputWindow", "vtkOutputWindow",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
0, 0, 512, 512,
0, 0, 800, 512,
NULL, NULL, GetModuleHandle(NULL), NULL);
#endif
......@@ -227,7 +227,7 @@ int vtkWin32OutputWindow::Initialize()
lpParam.hInstance = GetModuleHandle(NULL);
lpParam.hMenu = NULL;
lpParam.hwndParent = win;
lpParam.cx = 512;
lpParam.cx = 800;
lpParam.cy = 512;
lpParam.x = 0;
lpParam.y = 0;
......
......@@ -15,6 +15,5 @@ vtk_module(vtkCommonDataModel
vtkIOGeometry
vtkIOLegacy
vtkIOXML
vtkRenderingCore
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
)
......@@ -69,7 +69,7 @@ public:
this->Renderer = r;
}
void SetPicker(vtkAreaPicker *p)
void SetPicker(vtkAreaPicker *p)
{
this->Picker = p;
}
......@@ -243,10 +243,12 @@ int TestMoleculeSelection(int argc, char *argv[])
}
// Verify pick
if (com->GetAtomIds()->GetValue(0) != 0 ||
if (com->GetAtomIds()->GetNumberOfTuples() < 4 ||
com->GetAtomIds()->GetValue(0) != 0 ||
com->GetAtomIds()->GetValue(1) != 1 ||
com->GetAtomIds()->GetValue(2) != 4 ||
com->GetAtomIds()->GetValue(3) != 5 ||
com->GetBondIds()->GetNumberOfTuples() < 8 ||
com->GetBondIds()->GetValue(0) != 0 ||
com->GetBondIds()->GetValue(1) != 1 ||
com->GetBondIds()->GetValue(2) != 3 ||
......
......@@ -27,6 +27,12 @@
#include "vtkRenderer.h"
#include "vtkPDBReader.h"
#include "vtkTimerLog.h"
#include "vtkSmartPointer.h"
#include "vtkCamera.h"
int TestPDBBallAndStick(int argc, char *argv[])
{
char* fileName =
......@@ -65,6 +71,33 @@ int TestPDBBallAndStick(int argc, char *argv[])
ren->GetActiveCamera()->Zoom(1.7);
ren->SetBackground(0.0, 0.0, 0.0);
win->SetSize(450, 450);
vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New();
int numRenders = 85;
timer->StartTimer();
win->Render();
timer->StopTimer();
double firstRender = timer->GetElapsedTime();
cerr << "first render time: " << firstRender << endl;
timer->StartTimer();
for (int i = 0; i < numRenders; ++i)
{
ren->GetActiveCamera()->Azimuth(1);
ren->GetActiveCamera()->Elevation(1);
win->Render();
}
timer->StopTimer();
double elapsed = timer->GetElapsedTime();
cerr << "interactive render time: " << elapsed / numRenders << endl;
ren->GetActiveCamera()->SetPosition(0,0,1);
ren->GetActiveCamera()->SetFocalPoint(0,0,0);
ren->GetActiveCamera()->SetViewUp(0,1,0);
ren->ResetCamera();
ren->GetActiveCamera()->Zoom(1.7);
win->Render();
// Finally render the scene and compare the image to a reference image
......
......@@ -11,5 +11,5 @@ vtk_module(vtkDomainsChemistry
vtkTestingCore
vtkTestingRendering
vtkInteractionStyle
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
)
......@@ -14,5 +14,5 @@ vtk_module(vtkFiltersCore
vtkIOXML
vtkImagingCore
vtkFiltersGeneral
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
)
......@@ -10,7 +10,7 @@ vtk_module(vtkFiltersExtraction
TEST_DEPENDS
vtkIOLegacy
vtkIOXML
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingRendering
vtkInteractionStyle
)
......@@ -12,5 +12,5 @@ vtk_module(vtkFiltersFlowPaths
vtkTestingCore
vtkTestingRendering
vtkInteractionStyle
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
)
......@@ -30,6 +30,7 @@
#include "vtkCamera.h"
#include "vtkPointData.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkTriangleFilter.h"
int TestUncertaintyTubeFilter( int, char*[] )
{
......@@ -93,9 +94,14 @@ int TestUncertaintyTubeFilter( int, char*[] )
utf->SetInputData(pd);
utf->SetNumberOfSides(8);
vtkSmartPointer<vtkTriangleFilter> tf =
vtkSmartPointer<vtkTriangleFilter>::New();
tf->SetInputConnection(utf->GetOutputPort());
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection( utf->GetOutputPort() );
//mapper->SetInputConnection( utf->GetOutputPort() );
mapper->SetInputConnection( tf->GetOutputPort() );
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
......
46d21bb658859a6f44bb72b7153e898a
53b894e9fd7d893223b7649bdff8187a
......@@ -9,7 +9,7 @@ vtk_module(vtkFiltersGeneral
vtkIOXML
vtkImagingMath
vtkInteractionStyle
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingFreeTypeOpenGL
vtkRenderingAnnotation
vtkRenderingLabel
......
......@@ -7,7 +7,7 @@ vtk_module(vtkFiltersGeneric
TEST_DEPENDS
vtkIOXML
vtkIOLegacy
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
vtkRenderingFreeTypeOpenGL
vtkFiltersModeling
vtkRenderingLabel
......
......@@ -5,7 +5,7 @@ vtk_module(vtkFiltersGeometry
vtkFiltersCore
TEST_DEPENDS
vtkIOXML
vtkRenderingOpenGL
vtkRendering${VTK_RENDERING_BACKEND}
vtkTestingRendering
vtkInteractionStyle
)