diff --git a/CMake/modules/FindEpoxy.cmake b/CMake/modules/FindEpoxy.cmake new file mode 100644 index 000000000..9da299fdb --- /dev/null +++ b/CMake/modules/FindEpoxy.cmake @@ -0,0 +1,16 @@ +# Find libepoxy +# +# EPOXY_INCLUDE_DIR +# EPOXY_LIBRARY +# EPOXY_FOUND + +find_path(EPOXY_INCLUDE_DIR NAMES epoxy/gl.h PATHS /opt/vc/include) + +set(EPOXY_NAMES ${EPOXY_NAMES} epoxy) +find_library(EPOXY_LIBRARY NAMES ${EPOXY_NAMES} PATHS /opt/vc/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(EPOXY DEFAULT_MSG EPOXY_LIBRARY EPOXY_INCLUDE_DIR) + +mark_as_advanced(EPOXY_INCLUDE_DIR EPOXY_LIBRARY) + diff --git a/CMakeLists.txt b/CMakeLists.txt index e990b85b8..95d2bc07f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,7 @@ set(CMAKE_MODULE_PATH "${GLFW_SOURCE_DIR}/CMake/modules") if (GLFW_USE_EGL) set(GLFW_CLIENT_LIBRARY "opengl" CACHE STRING - "The client library to use; one of opengl, glesv1 or glesv2") + "The client library to use; one of opengl, glesv1, glesv2 or epoxy") if (${GLFW_CLIENT_LIBRARY} STREQUAL "opengl") set(_GLFW_USE_OPENGL 1) @@ -69,13 +69,15 @@ if (GLFW_USE_EGL) set(_GLFW_USE_GLESV1 1) elseif (${GLFW_CLIENT_LIBRARY} STREQUAL "glesv2") set(_GLFW_USE_GLESV2 1) + elseif (${GLFW_CLIENT_LIBRARY} STREQUAL "epoxy") + set(_GLFW_USE_EPOXY 1) else() message(FATAL_ERROR "Unsupported client library") endif() find_package(EGL REQUIRED) - if (NOT _GLFW_USE_OPENGL) + if (NOT _GLFW_USE_OPENGL AND NOT _GLFW_USE_EPOXY) set(GLFW_BUILD_EXAMPLES OFF) set(GLFW_BUILD_TESTS OFF) message(STATUS "NOTE: Examples and tests require OpenGL") @@ -90,6 +92,8 @@ elseif (_GLFW_USE_GLESV1) find_package(GLESv1 REQUIRED) elseif (_GLFW_USE_GLESV2) find_package(GLESv2 REQUIRED) +elseif (_GLFW_USE_EPOXY) + find_package(Epoxy REQUIRED) endif() find_package(Threads REQUIRED) @@ -400,6 +404,10 @@ if (_GLFW_EGL) list(APPEND glfw_LIBRARIES "${GLESv2_LIBRARY}") list(APPEND glfw_INCLUDE_DIRS "${GLESv2_INCLUDE_DIR}") list(APPEND glfw_PKG_DEPS "glesv2") + elseif (_GLFW_USE_EPOXY) + list(APPEND glfw_LIBRARIES "${EPOXY_LIBRARY}") + list(APPEND glfw_INCLUDE_DIRS "${EPOXY_INCLUDE_DIR}") + list(APPEND glfw_PKG_DEPS "epoxy") endif() endif() diff --git a/docs/build.dox b/docs/build.dox index aa6c5fe80..9018bf2bd 100644 --- a/docs/build.dox +++ b/docs/build.dox @@ -80,6 +80,9 @@ header instead of the regular OpenGL header. `GLFW_INCLUDE_ES31` makes the GLFW header include the OpenGL ES 3.1 `GLES3/gl31.h` header instead of the regular OpenGL header. +`GLFW_INCLUDE_EPOXY` makes the GLFW header include the libepoxy `epoxy/gl.h` +header instead of the regular OpenGL header. + `GLFW_INCLUDE_NONE` makes the GLFW header not include any OpenGL or OpenGL ES API header. This is useful in combination with an extension loading library. diff --git a/docs/compile.dox b/docs/compile.dox index 5c6175610..0fb11723e 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -281,6 +281,8 @@ through extensions. The options are: OpenGL.framework) - `_GLFW_USE_GLESV1` for OpenGL ES 1.x (experimental) - `_GLFW_USE_GLESV2` for OpenGL ES 2.x (experimental) + - `_GLFW_USE_EPOXY` for libepoxy to resolve which of the three previous ones + to use at runtime. Note that `_GLFW_USE_GLESV1` and `_GLFW_USE_GLESV2` may only be used with EGL, as the other context creation APIs do not interface with OpenGL ES client diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index 9a7ca1764..d82e67422 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -149,6 +149,8 @@ extern "C" { #if defined(GLFW_INCLUDE_GLEXT) #include #endif + #elif defined(GLFW_INCLUDE_EPOXY) + #include #elif !defined(GLFW_INCLUDE_NONE) #include #if defined(GLFW_INCLUDE_GLEXT) diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index 33296f5cc..fe15514ac 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -78,4 +78,6 @@ #cmakedefine _GLFW_USE_GLESV1 // Define this to 1 if using OpenGL ES 2.0 as the client library #cmakedefine _GLFW_USE_GLESV2 +// Define this to 1 if using libepoxy as the client library +#cmakedefine _GLFW_USE_EPOXY diff --git a/src/internal.h b/src/internal.h index 986f62302..b42835378 100644 --- a/src/internal.h +++ b/src/internal.h @@ -52,6 +52,8 @@ #define GLFW_INCLUDE_ES1 #elif defined(_GLFW_USE_GLESV2) #define GLFW_INCLUDE_ES2 +#elif defined(_GLFW_USE_EPOXY) + #define GLFW_INCLUDE_EPOXY #else #error "No supported client library selected" #endif