Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Support OpenGL ES on *nix systems (#55)
Browse files Browse the repository at this point in the history
* Support OpenGL ES on *nix systems

* support OpenGL ES on nix system (remove ES == mobile assumption)
  + add explicit options for both OGLES_GPGPU_OPENGL_ES{2,3}
    - these are mutually exclusive
    - if neither of the above is defined we use standard opengl (subset)
  + add OGLES_GPGPU_USE_EGL for EGL managed context (pass through to aglet)
* add generated header for OGLES_GPGPU_OPENGL_ES{2,3} version
  > w/ previous mobile == ES assumption this wasn't needed
  + update build with generated_file gl_definitions.h header to store defs
    > this wasn't needed in the exclusively mobile=es configuration
  + install generated gl_definitions.h header
  + introduce OGLES_GPGPU_NIX macro to indicate a nix variant
  + support includes of GLES2/gl2*.h, GLES3/gl3*.h, or GL/gl*.h headers as needed
  + update unit test to instantiate the correct context variant based on cmake options
* fix cmake logic in common_includes.h (android vs ios vs GL) for OGLES_GPGPU_OPENGL_ES{2,3} change
* video.h: use top level OGLES_GPGPU_TEXTURE_FORMAT, don't duplicate logic
* update aglet
  + bump version via URL + SHA1 in LOCAL config
  + translate OGLES_GPGPU_* -> AGLET_* options
* migrate test dependencies to unit test CMakeLists.txt
* update Hunter v0.23.151
* update HunterGate module
* bump version to v0.3.7

* update cmake package deps

* fix typo and cmake option location

* 's|ogesl_gpgpu|ogles_gpgpu'
* put required cmake options after project() and before hunter_add_package()

* fix opengl find_package() logic for *nix variants

* add include paths for mesa (test only) build
  • Loading branch information
headupinclouds committed Apr 6, 2019
1 parent 19017bd commit 1a23973
Show file tree
Hide file tree
Showing 11 changed files with 309 additions and 248 deletions.
65 changes: 28 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,34 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules")

include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.22.13.tar.gz"
SHA1 "8b361d14d17c3526d41ecb62b6e905bdd9f3ee1d"
URL "https://github.com/ruslo/hunter/archive/v0.23.151.tar.gz"
SHA1 "68657b81508c2d3c248731b5a0c2125f19866721"
LOCAL
)
)

project(ogles_gpgpu VERSION 0.3.6)
project(ogles_gpgpu VERSION 0.3.7)

hunter_add_package(check_ci_tag)
find_package(check_ci_tag CONFIG REQUIRED)
check_ci_tag()
# !!! Make sure option OGLES_GPGPU_OPENG_ES3 occurs prior to the first
# hunter_add_package() call. This will allow us to modify settings
# in dependencies appropriately (see cmake/Hunter/config.cmake)

if(IOS OR ANDROID)
set(ogles_gpgpu_opengl_es2_dflt ON)
set(ogles_gpgpu_opengl_es3_dflt OFF)
else()
set(ogles_gpgpu_opengl_es2_dflt OFF)
set(ogles_gpgpu_opengl_es3_dflt OFF)
endif()

option(OGLES_GPGPU_OPENGL_ES2 "Use OpenGL ES 2.0" ${ogles_gpgpu_opengl_es2_dflt})
option(OGLES_GPGPU_OPENGL_ES3 "Use OpenGL ES 3.0" ${ogles_gpgpu_opengl_es3_dflt})
option(OGLES_GPGPU_USE_EGL "Use EGL to manage the context (supports ES)" OFF)

if(OGLES_GPGPU_OPENGL_ES2 AND OGLES_GPGPU_OPENGL_ES3)
message(FATAL_ERROR
"OGLES_GPGPU_OPENGL_ES2 and OGLES_GPGPU_OPENGL_ES3 are mutually exclusive"
)
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

Expand All @@ -30,10 +48,9 @@ option(OGLES_GPGPU_VERBOSE "Perform per filter logging" OFF)
option(OGLES_GPGPU_BUILD_TESTS "Build shader unit tests" OFF)
option(OGLES_GPGPU_USE_OSMESA "Use MESA CPU OpenGL (via glfw)" OFF)

# !!! Make sure option OGLES_GPGPU_OPENG_ES3 occurs prior to the first
# hunter_add_package() call. This will allow us to modify settings
# in dependencies appropriately (see cmake/Hunter/config.cmake)
option(OGLES_GPGPU_OPENGL_ES3 "Use OpenGL ES 3.0" OFF)
hunter_add_package(check_ci_tag)
find_package(check_ci_tag CONFIG REQUIRED)
check_ci_tag()

# See: cmake/Hunter/config.cmake
hunter_add_package(sugar)
Expand Down Expand Up @@ -71,37 +88,11 @@ endif()
# but they may only be run on platforms where an OpenGL context
# is available
if(OGLES_GPGPU_BUILD_TESTS)

if(IOS AND DRISHTI_CI)
# do not run test on CI (TODO: remote device testing)
else()
enable_testing()
endif()

# Use GTest as unit test framework
hunter_add_package(GTest)
find_package(GTest CONFIG REQUIRED)
list(APPEND OGLES_GPGPU_TEST_LIBS GTest::gtest)

if(MSVC)
# TODO: Temporary aglet fix for appveyor? Shouldn't be needed.
hunter_add_package(glew)
find_package(glew CONFIG REQUIRED)
endif()

# Use aglet for portable lightweight off screen opengl context
hunter_add_package(aglet)
find_package(aglet CONFIG REQUIRED)
list(APPEND OGLES_GPGPU_TEST_LIBS aglet::aglet)

# Use gauze for cross platform ctesting
hunter_add_package(gauze)
find_package(gauze CONFIG REQUIRED)
list(APPEND OGLES_GPGPU_TEST_LIBS gauze::gauze)

hunter_add_package(OpenCV)
find_package(OpenCV REQUIRED)
list(APPEND OGLES_GPGPU_TEST_LIBS "${OpenCV_LIBS}")
endif()

## #################################################################
Expand Down
8 changes: 7 additions & 1 deletion cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ elseif(@APPLE@)
find_package(OpenGL REQUIRED)
endif()
else()
find_package(OpenGL REQUIRED)
if(@OGLES_GPGPU_OPENGL_ES2@)
find_package(gles2 REQUIRED)
elseif(@OGLES_GPGPU_OPENGL_ES3@)
find_package(gles3 REQUIRED)
else()
find_package(OpenGL REQUIRED)
endif()
endif()

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
Expand Down
24 changes: 12 additions & 12 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ if(OGLES_GPGPU_USE_OSMESA)
hunter_config(glfw VERSION ${HUNTER_glfw_VERSION} CMAKE_ARGS GLFW_USE_OSMESA=ON)
endif()

# Note: Aglet is currently used to provide an OpenGL context for the unit tests
# We need to make sure it is configured appropriately to provide one of:
# * OpenGL ES 3.0 (or OpenGL 3.0)
# * OpenGL ES 2.0
# The context must be allocated approprately and we need to pull in the correct
# set of headers with mixing them.
if(OGLES_GPGPU_OPENGL_ES3)
set(aglet_es3 ON)
else()
set(aglet_es3 OFF)
endif()
message("AGLET_OPENGL_ES3=${OGLES_GPGPU_OPENGL_ES3}")

set(aglet_url "https://github.com/elucideye/aglet/archive/v1.3.3.tar.gz")
set(aglet_sha1 432ad86638c30d221ad444ab73af214c2fe5a180)
set(aglet_args
"AGLET_USE_EGL=${OGLES_GPGPU_USE_EGL}"
"AGLET_OPENGL_ES2=${OGLES_GPGPU_OPENGL_ES2}"
"AGLET_OPENGL_ES3=${OGLES_GPGPU_OPENGL_ES3}"
)

#hunter_config(aglet VERSION ${HUNTER_aglet_VERSION} CMAKE_ARGS AGLET_OPENGL_ES3=${aglet_es3})
hunter_config(aglet URL ${aglet_url} SHA1 ${aglet_sha1} CMAKE_ARGS ${aglet_args})

hunter_config(aglet VERSION ${HUNTER_aglet_VERSION} CMAKE_ARGS AGLET_OPENGL_ES3=${aglet_es3})
Loading

0 comments on commit 1a23973

Please sign in to comment.