Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with VTK 9.3.20240914 #1620

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .cppcheck.supp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ unknownMacro
*:external/cxxopts/cxxopts.hpp
*:external/dmon/dmon.h

// function returning a function
*:library/testing/TestSDKExternalWindowGLFW.cxx
*:library/testing/TestSDKExternalWindowQT.cxx

// specific checks
knownConditionTrueFalse:library/testing/TestSDKImage.cxx
knownConditionTrueFalse:library/testing/TestSDKImageDeprecated.cxx
Expand Down
1 change: 1 addition & 0 deletions .github/actions/generic-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ runs:
-DF3D_PLUGIN_BUILD_USD=${{ inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }}
-DF3D_PLUGIN_BUILD_VDB=${{ matrix.vtk_version != 'v9.2.6' && (runner.os != 'Windows' || matrix.vtk_version != 'v9.3.1') && inputs.optional_deps_label == 'optional-deps' && 'ON' || 'OFF' }}
-DF3D_STRICT_BUILD=ON
-DF3D_TESTING_ENABLE_ONSCREEN_TESTS=${{ inputs.egl_label == 'egl' && 'OFF' || 'ON' }}
-DF3D_WINDOWS_GUI=ON
${{ runner.os == 'Windows' && '-Ax64 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL' || null }}
${{ runner.os == 'macOS' && '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15' || null }}
Expand Down
2 changes: 0 additions & 2 deletions .github/actions/vtk-install-dep/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ runs:
-DVTKOSPRAY_ENABLE_DENOISER=ON
-DVTK_BUILD_TESTING=OFF
-DVTK_DEBUG_LEAKS=ON
-DVTK_DEFAULT_RENDER_WINDOW_HEADLESS=${{ inputs.egl_label == 'egl' && 'ON' || 'OFF' }}
-DVTK_ENABLE_LOGGING=OFF
-DVTK_ENABLE_REMOTE_MODULES=OFF
-DVTK_ENABLE_WRAPPING=OFF
Expand Down Expand Up @@ -116,7 +115,6 @@ runs:
-DVTK_MODULE_ENABLE_VTK_RenderingRayTracing=${{ inputs.raytracing_label == 'raytracing' && 'YES' || 'DEFAULT' }}
-DVTK_MODULE_ENABLE_VTK_RenderingVolumeOpenGL2=YES
-DVTK_MODULE_ENABLE_VTK_TestingCore=YES
-DVTK_OPENGL_HAS_EGL=${{ inputs.egl_label == 'egl' && 'ON' || 'OFF' }}
-DVTK_SMP_IMPLEMENTATION_TYPE=TBB
-DVTK_VERSIONED_INSTALL=OFF
${{ runner.os == 'macOS' && '-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15' || null }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/vtk_commit_sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6a898fd91da30d3ff903416bf856f0d1cea82cdf
b300f41d8e0111e70f9c8844f587df8d8feeaec9
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ find_package(VTK 9.0 REQUIRED
RenderingVolumeOpenGL2
TestingCore
jsoncpp
opengl
OPTIONAL_COMPONENTS
opengl
IOExodus
IOOpenVDB
RenderingExternal
RenderingRayTracing)
message(STATUS "VTK ${VTK_VERSION} found")

if(VTK_VERSION VERSION_LESS 9.3.20240914)
# Not optional before
find_package(VTK 9.0 REQUIRED COMPONENTS opengl)
endif()

# Shared options between application and library
include(GNUInstallDirs)
cmake_dependent_option(F3D_WINDOWS_GUI "Build a non-console Win32 application" ON "WIN32" OFF)
Expand Down Expand Up @@ -184,6 +189,7 @@ list(APPEND f3d_link_options_public ${f3d_sanitizer_link_options})
option(BUILD_TESTING "Build the tests" OFF)
cmake_dependent_option(F3D_TESTING_ENABLE_RENDERING_TESTS "Enable rendering tests" ON "BUILD_TESTING" OFF)
cmake_dependent_option(F3D_TESTING_ENABLE_LONG_TIMEOUT_TESTS "Enable long timeout tests" OFF "BUILD_TESTING" OFF)
cmake_dependent_option(F3D_TESTING_ENABLE_ONSCREEN_TESTS "Enable test that require onscreen rendering" ON "F3D_TESTING_ENABLE_RENDERING_TESTS" OFF)
if(BUILD_TESTING)
enable_testing()
endif()
Expand Down
6 changes: 4 additions & 2 deletions application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,11 @@ if (F3D_MODULE_EXR)
target_compile_definitions(f3d PRIVATE F3D_MODULE_EXR)
endif ()

if(VTK_VERSION VERSION_LESS 9.3.20240914)
# Headless EGL build
if (VTK_OPENGL_HAS_EGL)
target_compile_definitions(f3d PRIVATE F3D_HEADLESS_BUILD)
if (VTK_OPENGL_HAS_EGL)
target_compile_definitions(f3d PRIVATE F3D_HEADLESS_BUILD)
mwestphal marked this conversation as resolved.
Show resolved Hide resolved
endif ()
endif ()

# F3D_STRICT_BUILD
Expand Down
23 changes: 15 additions & 8 deletions application/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ f3d_test(NAME TestVerboseAnimationWrongAnimationTimeLow DATA BoxAnimated.gltf AR
# Test exit hotkey
f3d_test(NAME TestInteractionSimpleExit DATA cow.vtp REGEXP "Interactor has been stopped" INTERACTION NO_BASELINE) #Escape;

if(UNIX AND NOT APPLE AND VTK_VERSION VERSION_GREATER_EQUAL 9.3.20240914)
f3d_test(NAME TestInteractionSimpleExitHeadless DATA cow.vtp REGEXP "Interactor has been stopped" INTERACTION NO_BASELINE) #Escape;
set_tests_properties(f3d::TestInteractionSimpleExitHeadless PROPERTIES ENVIRONMENT "DISPLAY=")
endif()

# No alternative baseline supports in F3D
if(F3D_MODULE_RAYTRACING)
f3d_test(NAME TestInteractionCheatsheetRaytracing DATA cow.vtp INTERACTION) #H
Expand Down Expand Up @@ -981,15 +986,17 @@ if(NOT F3D_MACOS_BUNDLE)
endif()
endif()

# TODO VTK_VERSION
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

# Watch testing require onscreen rendering
if(NOT VTK_OPENGL_HAS_EGL)
if(UNIX)
set(_f3d_os_script_ext "sh")
set(_f3d_os_script_exec "")
elseif(WIN32)
set(_f3d_os_script_ext "ps1")
find_program(_f3d_os_script_exec NAMES pwsh powershell)
endif()
if(UNIX)
set(_f3d_os_script_ext "sh")
set(_f3d_os_script_exec "")
elseif(WIN32)
set(_f3d_os_script_ext "ps1")
find_program(_f3d_os_script_exec NAMES pwsh powershell)
endif()

if(F3D_TESTING_ENABLE_ONSCREEN_TESTS)
# Custom bash/pwsh test for testing watch option
add_test (NAME f3d::TestWatch COMMAND ${_f3d_os_script_exec} ${CMAKE_CURRENT_SOURCE_DIR}/test_watch.${_f3d_os_script_ext} $<TARGET_FILE:f3d> ${F3D_SOURCE_DIR}/testing/data ${CMAKE_BINARY_DIR}/Testing/Temporary)
set_tests_properties(f3d::TestWatch PROPERTIES RUN_SERIAL TRUE)
Expand Down
2 changes: 2 additions & 0 deletions library/private/window_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class window_impl : public window
*/
window_impl(const options& options, Type type);

void initializeExternal(
f3d::window::F3DOpenGLLoaderFunction loader, void* openglContext = nullptr) override;
/**
* Default destructor
*/
Expand Down
5 changes: 5 additions & 0 deletions library/public/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class F3D_EXPORT window
*/
virtual Type getType() = 0;

typedef void (*F3DOpenGLAPIProc)();
typedef F3DOpenGLAPIProc (*F3DOpenGLLoaderFunction)(void* userptr, const char* name);
virtual void initializeExternal(
F3DOpenGLLoaderFunction loader, void* openglContext = nullptr) = 0;

/**
* Get the camera provided by the window.
*/
Expand Down
13 changes: 12 additions & 1 deletion library/src/interactor_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,18 @@ class interactor_impl::internals
void StopInteractor()
{
this->VTKInteractor->RemoveObservers(vtkCommand::TimerEvent);
this->VTKInteractor->ExitCallback();

vtkRenderWindow* renWin = this->Window.GetRenderWindow();
bool usingNative = renWin->IsA("vtkWin32OpenGLRenderWindow") ||
renWin->IsA("vtkCocoaRenderWindow") || renWin->IsA("vtkXOpenGLRenderWindow");
if (usingNative)
{
this->VTKInteractor->ExitCallback();
}
else
{
this->VTKInteractor->SetDone(true);
}
}

/**
Expand Down
17 changes: 16 additions & 1 deletion library/src/window_impl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <vtkCamera.h>
#include <vtkImageData.h>
#include <vtkImageExport.h>
#include <vtkOpenGLRenderWindow.h>
#include <vtkPNGReader.h>
#include <vtkPointGaussianMapper.h>
#include <vtkRenderWindow.h>
Expand Down Expand Up @@ -161,7 +162,9 @@ window_impl::window_impl(const options& options, Type type)
else if (type == Type::EXTERNAL)
{
#if F3D_MODULE_EXTERNAL_RENDERING
this->Internals->RenWin = vtkSmartPointer<vtkExternalOpenGLRenderWindow>::New();
vtkNew<vtkExternalOpenGLRenderWindow> extWin;
extWin->AutomaticWindowPositionAndResizeOff();
this->Internals->RenWin = extWin;
#else
throw engine::no_window_exception(
"Window type is external but F3D_MODULE_EXTERNAL_RENDERING is not enabled");
Expand Down Expand Up @@ -194,6 +197,18 @@ window_impl::Type window_impl::getType()
return this->Internals->WindowType;
}

//----------------------------------------------------------------------------
void window_impl::initializeExternal(
[[maybe_unused]] F3DOpenGLLoaderFunction loader, [[maybe_unused]] void* openglContext)
{
// Option to add default initialization? TODO
#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240914)
vtkOpenGLRenderWindow::SafeDownCast(this->Internals->RenWin)
->SetOpenGLSymbolLoader(loader, openglContext);
vtkOpenGLRenderWindow::SafeDownCast(this->Internals->RenWin)->vtkOpenGLRenderWindow::OpenGLInit();
#endif
}

//----------------------------------------------------------------------------
camera& window_impl::getCamera()
{
Expand Down
7 changes: 4 additions & 3 deletions library/testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ configure_file("${F3D_SOURCE_DIR}/testing/recordings/TestSDKInteractorDropFullSc
"${CMAKE_BINARY_DIR}/TestSDKInteractorDropFullScene.log") # world.obj; S

# External window tests
if(F3D_MODULE_EXTERNAL_RENDERING AND NOT VTK_OPENGL_HAS_EGL)
find_package(glfw3 QUIET)
# TODO better control of deps
if(F3D_MODULE_EXTERNAL_RENDERING AND F3D_TESTING_ENABLE_ONSCREEN_TESTS)
find_package(glfw3)
if(glfw3_FOUND)
list(APPEND libf3dSDKTests_list
TestSDKExternalWindowGLFW.cxx
)
endif()
find_package(Qt5 QUIET COMPONENTS OpenGL)
find_package(Qt5 COMPONENTS OpenGL)
if(Qt5_FOUND)
list(APPEND libf3dSDKTests_list
TestSDKExternalWindowQT.cxx
Expand Down
15 changes: 12 additions & 3 deletions library/testing/TestSDKExternalWindowGLFW.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

int TestSDKExternalWindowGLFW(int argc, char* argv[])
{
// create engine and load file
f3d::engine eng(f3d::window::Type::EXTERNAL);
eng.getLoader().loadGeometry(std::string(argv[1]) + "/data/cow.vtp");
eng.getWindow().setSize(300, 300);

// setup glfw window
if (!glfwInit())
Expand All @@ -35,8 +34,8 @@ int TestSDKExternalWindowGLFW(int argc, char* argv[])
std::cerr << "Can't create GLFW window." << std::endl;
return EXIT_FAILURE;
}

glfwMakeContextCurrent(window);

glfwSetWindowUserPointer(window, &eng);

// key callback
Expand All @@ -47,6 +46,16 @@ int TestSDKExternalWindowGLFW(int argc, char* argv[])
}
});

auto loadFunc = [](void*, const char* name) -> f3d::window::F3DOpenGLAPIProc {
if (name)
{
return glfwGetProcAddress(name);
}
return nullptr;
};
eng.getWindow().initializeExternal(loadFunc);
eng.getLoader().loadGeometry(std::string(argv[1]) + "/data/cow.vtp");

while (!glfwWindowShouldClose(window) && glfwGetTime() < 1.0)
{
eng.getWindow().render();
Expand Down
16 changes: 16 additions & 0 deletions library/testing/TestSDKExternalWindowQT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ class F3DWindow : public QOpenGLWindow
this->close();
}

void initializeGL() override
{
this->QOpenGLWindow::initializeGL();
auto loadFunc = [](void* userData, const char* name) -> f3d::window::F3DOpenGLAPIProc {
if (auto* context = reinterpret_cast<QOpenGLContext*>(userData))
{
if (auto* symbol = context->getProcAddress(name))
{
return symbol;
}
}
return nullptr;
};
mEngine.getWindow().initializeExternal(loadFunc, this->context());
}

void paintGL() override
{
mEngine.getWindow().render();
Expand Down
5 changes: 5 additions & 0 deletions testing/recordings/TestInteractionSimpleExitHeadless.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# StreamVersion 1.1
ExposeEvent 0 599 0 0 0 0
RenderEvent 0 599 0 0 0 0
KeyReleaseEvent -710 286 0 13 1 Return
KeyPressEvent -710 286 0 27 1 Escape
2 changes: 1 addition & 1 deletion vtkext/private/module/vtk.module
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ DEPENDS
VTK::RenderingCore
VTK::RenderingOpenGL2
VTK::RenderingVolumeOpenGL2
VTK::opengl
f3d::vtkext
PRIVATE_DEPENDS
VTK::CommonExecutionModel
Expand All @@ -27,6 +26,7 @@ PRIVATE_DEPENDS
VTK::RenderingCore
VTK::RenderingVolumeOpenGL2
OPTIONAL_DEPENDS
VTK::opengl
VTK::RenderingExternal
VTK::RenderingRayTracing
TEST_DEPENDS
Expand Down
17 changes: 11 additions & 6 deletions vtkext/private/module/vtkF3DCachedLUTTexture.cxx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#include "vtkF3DCachedLUTTexture.h"

#include "vtkImageData.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkTextureObject.h"
#include "vtkXMLImageDataReader.h"
#include <vtkImageData.h>
#include <vtkObjectFactory.h>
#include <vtkOpenGLRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkTextureObject.h>
#include <vtkVersion.h>
#include <vtkXMLImageDataReader.h>

#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240914)
#include <vtk_glad.h>
#else
#include <vtk_glew.h>
#endif

vtkStandardNewMacro(vtkF3DCachedLUTTexture);

Expand Down
22 changes: 14 additions & 8 deletions vtkext/private/module/vtkF3DCachedSpecularTexture.cxx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
#include "vtkF3DCachedSpecularTexture.h"

#include "vtkImageData.h"
#include "vtkMultiBlockDataSet.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkTextureObject.h"
#include "vtkXMLMultiBlockDataReader.h"

#include <vtkImageData.h>
#include <vtkMultiBlockDataSet.h>
#include <vtkObjectFactory.h>
#include <vtkOpenGLRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkTextureObject.h>
#include <vtkVersion.h>
#include <vtkXMLMultiBlockDataReader.h>

#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240914)
#include <vtk_glad.h>
#else
#include <vtk_glew.h>
#endif


vtkStandardNewMacro(vtkF3DCachedSpecularTexture);

Expand Down
12 changes: 9 additions & 3 deletions vtkext/private/module/vtkF3DPointSplatMapper.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "vtkF3DPointSplatMapper.h"

#include "vtkF3DBitonicSort.h"
#include "vtkF3DComputeDepthCS.h"

#include <vtkCamera.h>
#include <vtkObjectFactory.h>
#include <vtkOpenGLBufferObject.h>
Expand All @@ -14,10 +17,13 @@
#include <vtkPolyData.h>
#include <vtkShader.h>
#include <vtkShaderProgram.h>
#include <vtk_glew.h>
#include <vtkVersion.h>

#include "vtkF3DBitonicSort.h"
#include "vtkF3DComputeDepthCS.h"
#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240914)
#include <vtk_glad.h>
#else
#include <vtk_glew.h>
#endif

//----------------------------------------------------------------------------
class vtkF3DSplatMapperHelper : public vtkOpenGLPointGaussianMapperHelper
Expand Down
4 changes: 4 additions & 0 deletions vtkext/private/module/vtkF3DRenderer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@
#include <vtkOSPRayRendererNode.h>
#endif

#if VTK_VERSION_NUMBER >= VTK_VERSION_CHECK(9, 3, 20240914)
#include <vtk_glad.h>
#else
#include <vtk_glew.h>
#endif

#include <cctype>
#include <chrono>
Expand Down
Loading