diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 9220abb2c..ebfa23d5e 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -12,10 +12,6 @@ set(SRC ${SRCROOT}/Cursor.cpp ${INCROOT}/Cursor.hpp ${SRCROOT}/CursorImpl.hpp - ${SRCROOT}/EGLCheck.cpp - ${SRCROOT}/EGLCheck.hpp - ${SRCROOT}/EglContext.cpp - ${SRCROOT}/EglContext.hpp ${INCROOT}/Export.hpp ${SRCROOT}/GlContext.cpp ${SRCROOT}/GlContext.hpp @@ -63,8 +59,6 @@ if(SFML_OS_WINDOWS) ${SRCROOT}/Win32/CursorImpl.cpp ${SRCROOT}/Win32/ClipboardImpl.hpp ${SRCROOT}/Win32/ClipboardImpl.cpp - ${SRCROOT}/Win32/WglContext.cpp - ${SRCROOT}/Win32/WglContext.hpp ${SRCROOT}/Win32/InputImpl.cpp ${SRCROOT}/Win32/InputImpl.hpp ${SRCROOT}/Win32/JoystickImpl.cpp @@ -77,15 +71,40 @@ if(SFML_OS_WINDOWS) ${SRCROOT}/Win32/WindowImplWin32.cpp ${SRCROOT}/Win32/WindowImplWin32.hpp ) + if(SFML_OPENGL_ES) + set(PLATFORM_SRC + ${PLATFORM_SRC} + ${SRCROOT}/EGLCheck.cpp + ${SRCROOT}/EGLCheck.hpp + ${SRCROOT}/EglContext.cpp + ${SRCROOT}/EglContext.hpp + ) + else() + set(PLATFORM_SRC + ${PLATFORM_SRC} + ${SRCROOT}/Win32/WglContext.cpp + ${SRCROOT}/Win32/WglContext.hpp + ) + endif() source_group("windows" FILES ${PLATFORM_SRC}) # make sure that we use the Unicode version of the Win API functions add_definitions(-DUNICODE -D_UNICODE) elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) - if(SFML_USE_DRM) + if(SFML_OPENGL_ES) + set(PLATFORM_SRC + ${PLATFORM_SRC} + ${SRCROOT}/EGLCheck.cpp + ${SRCROOT}/EGLCheck.hpp + ${SRCROOT}/EglContext.cpp + ${SRCROOT}/EglContext.hpp + ) + elseif(SFML_USE_DRM) add_definitions(-DSFML_USE_DRM) set(PLATFORM_SRC ${PLATFORM_SRC} + ${SRCROOT}/EGLCheck.cpp + ${SRCROOT}/EGLCheck.hpp ${SRCROOT}/DRM/CursorImpl.hpp ${SRCROOT}/DRM/CursorImpl.cpp ${SRCROOT}/DRM/ClipboardImpl.hpp @@ -146,7 +165,6 @@ elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) ${SRCROOT}/NetBSD/JoystickImpl.cpp ${SRCROOT}/NetBSD/JoystickImpl.hpp ) - endif() source_group("unix" FILES ${PLATFORM_SRC}) elseif(SFML_OS_MACOSX) @@ -232,6 +250,10 @@ elseif(SFML_OS_IOS) source_group("ios" FILES ${PLATFORM_SRC}) elseif(SFML_OS_ANDROID) set(PLATFORM_SRC + ${SRCROOT}/EGLCheck.cpp + ${SRCROOT}/EGLCheck.hpp + ${SRCROOT}/EglContext.cpp + ${SRCROOT}/EglContext.hpp ${SRCROOT}/Android/CursorImpl.hpp ${SRCROOT}/Android/CursorImpl.cpp ${SRCROOT}/Android/ClipboardImpl.hpp diff --git a/src/SFML/Window/DRM/DRMContext.cpp b/src/SFML/Window/DRM/DRMContext.cpp index 916760343..7936aaaab 100644 --- a/src/SFML/Window/DRM/DRMContext.cpp +++ b/src/SFML/Window/DRM/DRMContext.cpp @@ -37,6 +37,14 @@ #include #include +// We check for this definition in order to avoid multiple definitions of GLAD +// entities during unity builds of SFML. +#ifndef SF_GLAD_EGL_IMPLEMENTATION_INCLUDED +#define SF_GLAD_EGL_IMPLEMENTATION_INCLUDED +#define SF_GLAD_EGL_IMPLEMENTATION +#include +#endif + namespace { bool initialized = false; @@ -168,11 +176,15 @@ namespace if (display == EGL_NO_DISPLAY) { + gladLoaderLoadEGL(EGL_NO_DISPLAY); + eglCheck(display = eglGetDisplay(reinterpret_cast(gbmDevice))); EGLint major, minor; eglCheck(eglInitialize(display, &major, &minor)); + gladLoaderLoadEGL(display); + #if defined(SFML_OPENGL_ES) if (!eglBindAPI(EGL_OPENGL_ES_API)) { diff --git a/src/SFML/Window/DRM/DRMContext.hpp b/src/SFML/Window/DRM/DRMContext.hpp index efa742644..dbd2ca0f3 100644 --- a/src/SFML/Window/DRM/DRMContext.hpp +++ b/src/SFML/Window/DRM/DRMContext.hpp @@ -35,9 +35,7 @@ #include #include #include -#define EGL_NO_X11 -#define MESA_EGL_NO_X11_HEADERS -#include +#include #include #include diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index ba9ea2b77..2ad165ef3 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -27,7 +27,6 @@ //////////////////////////////////////////////////////////// #include #include -#include #include #include #include @@ -48,6 +47,7 @@ #if defined(SFML_OPENGL_ES) + #include typedef sf::priv::EglContext ContextType; #else @@ -61,6 +61,7 @@ #if defined(SFML_OPENGL_ES) + #include typedef sf::priv::EglContext ContextType; #elif defined(SFML_USE_DRM) @@ -87,6 +88,7 @@ #elif defined(SFML_SYSTEM_ANDROID) + #include typedef sf::priv::EglContext ContextType; #endif