From 661500c4f5522057da3cb6c98a1a0e6479d2da59 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 18 Feb 2024 18:13:32 +0100 Subject: [PATCH] use epoxy instead of GLEW on Linux --- components/pango_display/src/display.cpp | 2 ++ components/pango_opengl/CMakeLists.txt | 32 ++++++++----------- .../include/pangolin/gl/glplatform.h | 4 ++- examples/VBODisplay/main.cpp | 14 +++++--- package.xml | 1 + scripts/install_prerequisites.sh | 4 +-- 6 files changed, 32 insertions(+), 25 deletions(-) diff --git a/components/pango_display/src/display.cpp b/components/pango_display/src/display.cpp index cc4f4a46e..a754126f4 100644 --- a/components/pango_display/src/display.cpp +++ b/components/pango_display/src/display.cpp @@ -152,7 +152,9 @@ WindowInterface& CreateWindowAndBind(std::string window_title, int w, int h, con } context->MakeCurrent(); +#ifdef HAVE_GLEW glewInit(); +#endif // And finally process pending window events (such as resize) now that we've setup our callbacks. context->window->ProcessEvents(); diff --git a/components/pango_opengl/CMakeLists.txt b/components/pango_opengl/CMakeLists.txt index 88c0566a2..a34a57738 100644 --- a/components/pango_opengl/CMakeLists.txt +++ b/components/pango_opengl/CMakeLists.txt @@ -24,7 +24,7 @@ PRIVATE find_package(Eigen3 REQUIRED NO_MODULE) message(STATUS "Found Eigen: '${EIGEN3_INCLUDE_DIRS}'") -target_compile_definitions(${COMPONENT} PUBLIC HAVE_EIGEN HAVE_GLEW) +target_compile_definitions(${COMPONENT} PUBLIC HAVE_EIGEN) set_target_properties( ${COMPONENT} PROPERTIES VERSION ${PANGOLIN_VERSION} SOVERSION ${PANGOLIN_VERSION_MAJOR} @@ -40,29 +40,25 @@ install(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/include" ) if(EMSCRIPTEN) - target_compile_definitions(${COMPONENT} PUBLIC HAVE_GLES HAVE_GLES_2) + target_compile_definitions(${COMPONENT} PUBLIC HAVE_GLES HAVE_GLES_2 HAVE_GLEW) target_sources( ${COMPONENT} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src/compat/gl2engine.cpp) else() - if(_LINUX_) - set(OpenGL_GL_PREFERENCE "GLVND") - endif() - find_package(OpenGL REQUIRED QUIET) - find_package(GLEW REQUIRED QUIET) - target_include_directories( ${COMPONENT} PUBLIC - $ - ) - target_link_libraries( ${COMPONENT} PUBLIC - ${GLEW_LIBRARY} - ) - if(_LINUX_) # EGL specific + set(OpenGL_GL_PREFERENCE "GLVND") find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL) - target_link_libraries(${COMPONENT} PUBLIC ${GLEW_LIBRARY} OpenGL::EGL) - target_include_directories( ${COMPONENT} PUBLIC $) + find_package(epoxy REQUIRED) + target_link_libraries(${COMPONENT} PUBLIC epoxy::epoxy OpenGL::EGL) + target_include_directories(${COMPONENT} PUBLIC $) + target_compile_definitions(${COMPONENT} PUBLIC HAVE_EPOXY) else() # OpenGL defaults - target_link_libraries(${COMPONENT} PUBLIC ${GLEW_LIBRARY} ${OPENGL_LIBRARIES}) - target_include_directories( ${COMPONENT} PUBLIC $) + find_package(OpenGL REQUIRED) + find_package(GLEW REQUIRED) + target_include_directories(${COMPONENT} PUBLIC $) + target_link_libraries(${COMPONENT} PUBLIC ${GLEW_LIBRARY}) + target_link_libraries(${COMPONENT} PUBLIC ${OPENGL_LIBRARIES}) + target_include_directories(${COMPONENT} PUBLIC $) + target_compile_definitions(${COMPONENT} PUBLIC HAVE_GLEW) endif() endif() diff --git a/components/pango_opengl/include/pangolin/gl/glplatform.h b/components/pango_opengl/include/pangolin/gl/glplatform.h index 94ea1baf4..795d0cb56 100644 --- a/components/pango_opengl/include/pangolin/gl/glplatform.h +++ b/components/pango_opengl/include/pangolin/gl/glplatform.h @@ -55,8 +55,10 @@ #undef ERROR #endif -#ifdef HAVE_GLEW +#if defined(HAVE_GLEW) #include +#elif defined(HAVE_EPOXY) + #include #endif #ifdef HAVE_GLES diff --git a/examples/VBODisplay/main.cpp b/examples/VBODisplay/main.cpp index 6b7f778a4..601d1ae7f 100644 --- a/examples/VBODisplay/main.cpp +++ b/examples/VBODisplay/main.cpp @@ -1,6 +1,10 @@ #include -#include +#if defined(HAVE_GLEW) + #include +#elif defined(HAVE_EPOXY) + #include +#endif #include #include @@ -24,10 +28,12 @@ int main( int /*argc*/, char* argv[] ) // cudaGLSetGLDevice(0); pangolin::CreateWindowAndBind("Main",640,480); +#ifdef HAVE_GLEW glewInit(); - - // 3D Mouse handler requires depth testing to be enabled - glEnable(GL_DEPTH_TEST); +#endif + + // 3D Mouse handler requires depth testing to be enabled + glEnable(GL_DEPTH_TEST); // Create vertex and colour buffer objects and register them with CUDA GlBufferCudaPtr vertex_array( diff --git a/package.xml b/package.xml index 3bdf04b24..b829e56b1 100644 --- a/package.xml +++ b/package.xml @@ -11,6 +11,7 @@ cmake libglew-dev + libepoxy-dev python3-dev eigen libpng-dev diff --git a/scripts/install_prerequisites.sh b/scripts/install_prerequisites.sh index 31ae2949c..badd1b472 100755 --- a/scripts/install_prerequisites.sh +++ b/scripts/install_prerequisites.sh @@ -120,7 +120,7 @@ if [[ "$MANAGER" == "apt" ]]; then PKGS_OPTIONS+=(install --no-install-suggests --no-install-recommends) if ((DRYRUN > 0)); then PKGS_OPTIONS+=(--dry-run); SUDO=""; fi PKGS_REQUIRED+=(libgl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols libegl1-mesa-dev) - PKGS_REQUIRED+=(libc++-dev libglew-dev libeigen3-dev cmake g++ ninja-build) + PKGS_REQUIRED+=(libc++-dev libepoxy-dev libglew-dev libeigen3-dev cmake g++ ninja-build) PKGS_RECOMMENDED+=(libjpeg-dev libpng-dev catch2) PKGS_RECOMMENDED+=(libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev) PKGS_ALL+=(libdc1394-dev libraw1394-dev libopenni-dev python3-dev python3-distutils) @@ -129,7 +129,7 @@ elif [[ "$MANAGER" == "dnf" ]]; then PKGS_UPDATE="dnf check-update" PKGS_OPTIONS+=(install) PKGS_REQUIRED+=(wayland-devel libxkbcommon-devel g++ ninja-build) - PKGS_REQUIRED+=(glew-devel eigen3 cmake) + PKGS_REQUIRED+=(epoxy-devel eigen3 cmake) PKGS_RECOMMENDED+=(libjpeg-devel libpng-devel OpenEXR-devel catch2) PKGS_ALL+=(libdc1394-devel libraw1394-devel librealsense-devel openni-devel) if ((DRYRUN > 0)); then