Skip to content

Commit

Permalink
use epoxy instead of GLEW on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrauch committed Feb 24, 2024
1 parent 3587d55 commit 465713f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 25 deletions.
2 changes: 2 additions & 0 deletions components/pango_display/src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
32 changes: 14 additions & 18 deletions components/pango_opengl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

target_link_libraries(${COMPONENT} PUBLIC pango_core pango_image Eigen3::Eigen)
target_include_directories(${COMPONENT} PUBLIC
Expand All @@ -36,29 +36,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
$<BUILD_INTERFACE:${GLEW_INCLUDE_DIR}>
)
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 $<BUILD_INTERFACE:${OPENGL_EGL_INCLUDE_DIRS}>)
find_package(epoxy REQUIRED)
target_link_libraries(${COMPONENT} PUBLIC epoxy::epoxy OpenGL::EGL)
target_include_directories(${COMPONENT} PUBLIC $<BUILD_INTERFACE:${OPENGL_EGL_INCLUDE_DIRS}>)
target_compile_definitions(${COMPONENT} PUBLIC HAVE_EPOXY)
else()
# OpenGL defaults
target_link_libraries(${COMPONENT} PUBLIC ${GLEW_LIBRARY} ${OPENGL_LIBRARIES})
target_include_directories( ${COMPONENT} PUBLIC $<BUILD_INTERFACE:${OPENGL_INCLUDE_DIR}>)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
target_include_directories(${COMPONENT} PUBLIC $<BUILD_INTERFACE:${GLEW_INCLUDE_DIR}>)
target_link_libraries(${COMPONENT} PUBLIC ${GLEW_LIBRARY})
target_link_libraries(${COMPONENT} PUBLIC ${OPENGL_LIBRARIES})
target_include_directories(${COMPONENT} PUBLIC $<BUILD_INTERFACE:${OPENGL_INCLUDE_DIR}>)
target_compile_definitions(${COMPONENT} PUBLIC HAVE_GLEW)
endif()
endif()
4 changes: 3 additions & 1 deletion components/pango_opengl/include/pangolin/gl/glplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@
#undef ERROR
#endif

#ifdef HAVE_GLEW
#if defined(HAVE_GLEW)
#include <GL/glew.h>
#elif defined(HAVE_EPOXY)
#include <epoxy/gl.h>
#endif

#ifdef HAVE_GLES
Expand Down
14 changes: 10 additions & 4 deletions examples/VBODisplay/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <iostream>

#include <GL/glew.h>
#if defined(HAVE_GLEW)
#include <GL/glew.h>
#elif defined(HAVE_EPOXY)
#include <epoxy/gl.h>
#endif

#include <pangolin/pangolin.h>
#include <pangolin/gl/glcuda.h>
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<buildtool_depend>cmake</buildtool_depend>

<depend>libglew-dev</depend>
<depend>libepoxy-dev</depend>
<depend>python3-dev</depend>
<build_depend>eigen</build_depend>
<depend>libpng-dev</depend>
Expand Down
4 changes: 2 additions & 2 deletions scripts/install_prerequisites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 465713f

Please sign in to comment.