diff --git a/CMakeLists.txt b/CMakeLists.txt index b9d301cba..354544c7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,21 +3,27 @@ ######################################################################## # # Project-wide settings -CMAKE_MINIMUM_REQUIRED(VERSION 3.10) +CMAKE_MINIMUM_REQUIRED(VERSION 3.18) IF(POLICY CMP0011) + # Included scripts do automatic cmake_policy() PUSH and POP. CMAKE_POLICY(SET CMP0011 NEW) ENDIF() -IF(POLICY CMP0072) - CMAKE_POLICY(SET CMP0072 NEW) -ENDIF() IF(POLICY CMP0074) + # find_package() uses _ROOT variables. CMAKE_POLICY(SET CMP0074 NEW) ENDIF() IF(POLICY CMP0104) + # Initialize CMAKE_CUDA_ARCHITECTURES when CMAKE_CUDA_COMPILER_ID is NVIDIA. Raise an error if CUDA_ARCHITECTURES is empty. CMAKE_POLICY(SET CMP0104 NEW) ENDIF() IF(POLICY CMP0146) - CMAKE_POLICY(SET CMP0146 OLD) # not required, but forced by OpenCV old support for CUDA + # Use CMake's first-class CUDA language support instead of FindCUDA(). + # note: not required, but forced by OpenCV old support for CUDA + CMAKE_POLICY(SET CMP0146 OLD) +ENDIF() +IF(POLICY CMP0167) + # The FindBoost module is removed. + CMAKE_POLICY(SET CMP0167 NEW) ENDIF() # List configuration options @@ -100,17 +106,6 @@ if(OpenMVS_USE_OPENMP) endif() endif() -if(OpenMVS_USE_OPENGL) - FIND_PACKAGE(OpenGL) - if(OPENGL_FOUND) - INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) - ADD_DEFINITIONS(${OpenGL_DEFINITIONS}) - SET(_USE_OPENGL TRUE) - else() - MESSAGE("-- Can't find OpenGL. Continuing without it.") - endif() -endif() - if(OpenMVS_USE_CUDA) INCLUDE(CheckLanguage) CHECK_LANGUAGE(CUDA) @@ -208,10 +203,6 @@ if(Boost_FOUND) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) ADD_DEFINITIONS(${Boost_DEFINITIONS}) LINK_DIRECTORIES(${Boost_LIBRARY_DIRS}) - if(NOT MSVC AND DEFINED CMAKE_TOOLCHAIN_FILE) - # work around this missing library link in vcpkg - LIST(APPEND Boost_LIBRARIES zstd) - endif() SET(_USE_BOOST TRUE) if(OpenMVS_USE_PYTHON AND Boost_${Boost_EXTRA_COMPONENTS}_FOUND) SET(_USE_BOOST_PYTHON TRUE) diff --git a/apps/Viewer/CMakeLists.txt b/apps/Viewer/CMakeLists.txt index bbdc6c6f1..9d89a1948 100644 --- a/apps/Viewer/CMakeLists.txt +++ b/apps/Viewer/CMakeLists.txt @@ -1,26 +1,18 @@ -if((NOT OpenMVS_USE_OPENGL) OR (NOT _USE_OPENGL)) - RETURN() -endif() - if(NOT VIEWER_NAME) set(VIEWER_NAME "Viewer") endif() # Find required packages -FIND_PACKAGE(GLEW QUIET) -if(GLEW_FOUND) - INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIRS}) - ADD_DEFINITIONS(${GLEW_DEFINITIONS}) - MESSAGE(STATUS "GLEW ${GLEW_VERSION} found (include: ${GLEW_INCLUDE_DIRS})") +FIND_PACKAGE(glad QUIET) +if(glad_FOUND) + MESSAGE(STATUS "GLAD ${glad_VERSION} found") else() - MESSAGE("-- Can't find GLEW. Continuing without it.") + MESSAGE("-- Can't find GLAD. Continuing without it.") RETURN() endif() FIND_PACKAGE(glfw3 QUIET) if(glfw3_FOUND) - INCLUDE_DIRECTORIES(${glfw3_INCLUDE_DIRS}) - ADD_DEFINITIONS(${glfw3_DEFINITIONS}) - MESSAGE(STATUS "GLFW3 ${glfw3_VERSION} found (include: ${glfw3_INCLUDE_DIRS})") + MESSAGE(STATUS "GLFW3 ${glfw3_VERSION} found") else() MESSAGE("-- Can't find GLFW3. Continuing without it.") RETURN() @@ -35,7 +27,7 @@ else() endif() FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl") -cxx_executable_with_flags(${VIEWER_NAME} "Apps" "${cxx_default}" "MVS;${OPENGL_LIBRARIES};${GLEW_LIBRARY};${GLFW_STATIC_LIBRARIES};GLEW::GLEW;${glfw3_LIBRARY};${GLFW3_LIBRARY};glfw;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) +cxx_executable_with_flags(${VIEWER_NAME} "Apps" "${cxx_default}" "MVS;glad::glad;${GLFW_STATIC_LIBRARIES};${glfw3_LIBRARY};${GLFW3_LIBRARY};glfw;${OpenMVS_EXTRA_LIBS}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H}) # Manually set Common.h as the precompiled header IF(CMAKE_VERSION VERSION_GREATER_EQUAL 3.16.0) diff --git a/apps/Viewer/Common.h b/apps/Viewer/Common.h index f3387834e..ff2f0dc53 100644 --- a/apps/Viewer/Common.h +++ b/apps/Viewer/Common.h @@ -35,17 +35,12 @@ // I N C L U D E S ///////////////////////////////////////////////// -#include #include "../../libs/MVS/Common.h" #include "../../libs/MVS/Scene.h" -#if defined(_MSC_VER) -#include -#elif defined(__APPLE__) -#include -#else -#include -#endif +#define GLAD_GL_IMPLEMENTATION +#include +#define GLFW_INCLUDE_NONE #include diff --git a/apps/Viewer/Scene.cpp b/apps/Viewer/Scene.cpp index 8053bb5cc..31ee33c59 100644 --- a/apps/Viewer/Scene.cpp +++ b/apps/Viewer/Scene.cpp @@ -186,8 +186,9 @@ bool Scene::Init(const cv::Size& size, LPCTSTR windowName, LPCTSTR fileName, LPC return false; if (!window.Init(size, windowName)) return false; - if (glewInit() != GLEW_OK) + if (gladLoadGL() == 0) return false; + VERBOSE("OpenGL: %s %s", glGetString(GL_RENDERER), glGetString(GL_VERSION)); name = windowName; window.clbkOpenScene = DELEGATEBINDCLASS(Window::ClbkOpenScene, &Scene::Open, this); diff --git a/apps/Viewer/Window.cpp b/apps/Viewer/Window.cpp index 90d891126..9eacf6d6c 100644 --- a/apps/Viewer/Window.cpp +++ b/apps/Viewer/Window.cpp @@ -62,9 +62,6 @@ Window::~Window() void Window::Release() { if (IsValid()) { - #ifdef _USE_NUKLEAR - nk_glfw3_shutdown(); - #endif glfwDestroyWindow(window); window = NULL; } @@ -205,14 +202,6 @@ void Window::UpdateMousePosition(double xpos, double ypos) } -void Window::GetFrame(Image8U3& image) const -{ - image.create(GetSize()); - glReadPixels(0, 0, image.width(), image.height(), GL_BGR_EXT, GL_UNSIGNED_BYTE, image.ptr()); - cv::flip(image, image, 0); -} - - cv::Size Window::GetSize() const { cv::Size _size; diff --git a/apps/Viewer/Window.h b/apps/Viewer/Window.h index ad9a957d0..188be99ed 100644 --- a/apps/Viewer/Window.h +++ b/apps/Viewer/Window.h @@ -139,8 +139,6 @@ class Window void UpdateView(const Eigen::Matrix3d& R, const Eigen::Vector3d& t); void UpdateMousePosition(double xpos, double ypos); - void GetFrame(Image8U3&) const; - cv::Size GetSize() const; void Resize(const cv::Size&); static void Resize(GLFWwindow* window, int width, int height); diff --git a/build/Templates/ConfigLocal.h.in b/build/Templates/ConfigLocal.h.in index 0ca0e239a..4a14fb894 100644 --- a/build/Templates/ConfigLocal.h.in +++ b/build/Templates/ConfigLocal.h.in @@ -39,9 +39,6 @@ // TIFF codec #cmakedefine _USE_TIFF -// OpenGL support -#cmakedefine _USE_OPENGL - // OpenCL support #cmakedefine _USE_OPENCL #cmakedefine _USE_OPENCL_STATIC diff --git a/libs/MVS/DepthMap.cpp b/libs/MVS/DepthMap.cpp index 4ae4ef36e..f3fa2164f 100644 --- a/libs/MVS/DepthMap.cpp +++ b/libs/MVS/DepthMap.cpp @@ -266,7 +266,7 @@ bool DepthData::Load(const String& fileName, unsigned flags) Camera camera; if (!ImportDepthDataRaw(fileName, imageFileName, IDs, imageSize, camera.K, camera.R, camera.C, dMin, dMax, depthMap, normalMap, confMap, viewsMap, flags)) return false; - ASSERT(!IsValid() || (IDs.size() == images.size() && IDs.front() == GetView().GetID())); + ASSERT(!IDs.empty() && (!IsValid() || IDs.front() == GetView().GetID())); ASSERT(depthMap.size() == imageSize); ASSERT(depthMap.size() == size); return true; @@ -1834,7 +1834,7 @@ bool MVS::ExportDepthDataRaw(const String& fileName, const String& imageFileName Depth dMin, Depth dMax, const DepthMap& depthMap, const NormalMap& normalMap, const ConfidenceMap& confMap, const ViewsMap& viewsMap) { - ASSERT(IDs.size() > 1 && IDs.size() < 256); + ASSERT(!IDs.empty() && IDs.size() < 256); ASSERT(!depthMap.empty()); ASSERT(confMap.empty() || depthMap.size() == confMap.size()); ASSERT(viewsMap.empty() || depthMap.size() == viewsMap.size()); diff --git a/libs/MVS/SceneReconstruct.cpp b/libs/MVS/SceneReconstruct.cpp index a6c6d5cce..5092f8f97 100644 --- a/libs/MVS/SceneReconstruct.cpp +++ b/libs/MVS/SceneReconstruct.cpp @@ -38,8 +38,8 @@ #include #include #include -#include -#include +#include +#include #include using namespace MVS; diff --git a/vcpkg.json b/vcpkg.json index 6c4891c03..0e181e49b 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -14,7 +14,7 @@ "default-features": false }, "eigen3", - "glew", + "glad", "glfw3", "libpng", { @@ -24,7 +24,6 @@ "openexr" ] }, - "opengl", "tiff", "vcglib", "zlib"