EGLDevice: Fix build after rebase
Some minor bitrot had occurred since the patch was made.
Related to #786.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 467fc7a..ea65cae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,8 +41,9 @@
endif()
if (UNIX AND NOT APPLE)
- option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF)
- option(GLFW_USE_MIR "Use Mir for window creation" OFF)
+ option(GLFW_USE_WAYLAND "Use Wayland for window creation" OFF)
+ option(GLFW_USE_MIR "Use Mir for window creation" OFF)
+ option(GLFW_USE_EGLDEVICE "Use EGLDevice for window creation" OFF)
endif()
if (MSVC)
@@ -299,8 +300,15 @@
#--------------------------------------------------------------------
if (_GLFW_EGLDEVICE)
+ find_path(DRM_INCLUDE_DIR NAMES drm.h PATH_SUFFIXES drm libdrm)
+ if (NOT DRM_INCLUDE_DIR)
+ message(FATAL_ERROR "The libdrm headers were not found")
+ endif()
+
+ list(APPEND glfw_INCLUDE_DIRS "${DRM_INCLUDE_DIR}")
+
list(APPEND glfw_LIBRARIES "-ldrm")
- list(APPEND glfw_LIBRARIES "-lpthread")
+ list(APPEND glfw_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}")
endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7be4a07..226cc19 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -49,9 +49,9 @@
BASENAME pointer-constraints-unstable-v1)
elseif(_GLFW_EGLDEVICE)
set(glfw_HEADERS ${common_HEADERS} egldevice_platform.h linux_joystick.h
- posix_time.h posix_tls.h xkb_unicode.h egl_context.h)
+ posix_time.h posix_thread.h xkb_unicode.h egl_context.h)
set(glfw_SOURCES ${common_SOURCES} egldevice_init.c egldevice_monitor.c egldevice_window.c
- linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c
+ linux_joystick.c posix_time.c posix_thread.c xkb_unicode.c
egl_context.c)
elseif (_GLFW_MIR)
set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h
@@ -94,7 +94,7 @@
target_compile_definitions(glfw PRIVATE
_GLFW_USE_CONFIG_H
- $<$<BOOL:${UNIX}>:_XOPEN_SOURCE=600>)
+ $<$<BOOL:${UNIX}>:_POSIX_C_SOURCE=200809L>)
target_include_directories(glfw PUBLIC
"$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>")
diff --git a/src/egl_context.c b/src/egl_context.c
index bef7525..6f2a425 100644
--- a/src/egl_context.c
+++ b/src/egl_context.c
@@ -118,7 +118,7 @@
#if defined(_GLFW_EGLDEVICE)
// Only consider stream EGLConfigs
- if (!(getConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_STREAM_BIT_KHR))
+ if (!(getEGLConfigAttrib(n, EGL_SURFACE_TYPE) & EGL_STREAM_BIT_KHR))
continue;
#else
diff --git a/src/egl_context.h b/src/egl_context.h
index b27cac9..eed35bb 100644
--- a/src/egl_context.h
+++ b/src/egl_context.h
@@ -48,7 +48,9 @@
typedef MirEGLNativeDisplayType EGLNativeDisplayType;
typedef MirEGLNativeWindowType EGLNativeWindowType;
#elif defined(_GLFW_EGLDEVICE)
- #include <EGL/eglplatform.h>
+ #define EGLAPIENTRY
+typedef void* EGLNativeDisplayType;
+typedef int EGLNativeWindowType;
#else
#error "No supported EGL platform selected"
#endif
@@ -86,6 +88,8 @@
#define EGL_OPENGL_ES_API 0x30a0
#define EGL_OPENGL_API 0x30a2
#define EGL_NONE 0x3038
+#define EGL_WIDTH 0x3057
+#define EGL_HEIGHT 0x3056
#define EGL_EXTENSIONS 0x3055
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
#define EGL_NATIVE_VISUAL_ID 0x302e
@@ -120,6 +124,7 @@
typedef void* EGLContext;
typedef void* EGLDisplay;
typedef void* EGLSurface;
+typedef intptr_t EGLAttrib;
// EGL function pointer typedefs
typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
diff --git a/src/egldevice_init.c b/src/egldevice_init.c
index 6940573..1372895 100644
--- a/src/egldevice_init.c
+++ b/src/egldevice_init.c
@@ -27,7 +27,6 @@
#include "internal.h"
#include <linux/limits.h>
-#include "egl_context.h"
static GLFWbool initializeExtensions()
{
@@ -187,10 +186,7 @@
if (!eglInitialize(_glfw.egl.display, &_glfw.egl.major, &_glfw.egl.minor))
{
- _glfwInputError(GLFW_API_UNAVAILABLE,
- "EGL: Failed to initialize EGL: %s",
- eglGetError());
-
+ _glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to initialize EGL");
return GLFW_FALSE;
}
@@ -252,9 +248,6 @@
EGLDeviceEXT egl_dev;
int drm_fd;
- if (!_glfwInitThreadLocalStoragePOSIX())
- return GLFW_FALSE;
-
// Initialize EGL
if (!_glfwInitEGL())
return GLFW_FALSE;
@@ -278,6 +271,8 @@
_glfwInitTimerPOSIX();
+ _glfwPollMonitorsEGLDevice();
+
return GLFW_TRUE;
}
@@ -285,15 +280,11 @@
{
_glfwTerminateEGL();
_glfwTerminateJoysticksLinux();
- _glfwTerminateThreadLocalStoragePOSIX();
}
const char* _glfwPlatformGetVersionString(void)
{
- return _GLFW_VERSION_NUMBER "EGLDEVICE"
-#if defined(_GLFW_EGL)
- " EGL"
-#endif
+ return _GLFW_VERSION_NUMBER "EGLDevice EGL"
#if defined(_GLFW_BUILD_DLL)
" shared"
#endif
diff --git a/src/egldevice_monitor.c b/src/egldevice_monitor.c
index 388b23d..4024df9 100644
--- a/src/egldevice_monitor.c
+++ b/src/egldevice_monitor.c
@@ -117,30 +117,18 @@
/////////// GLFW platform API //////////////
/////////////////////////////////////////////////////////////////////////////
-_GLFWmonitor** _glfwPlatformGetMonitors(int* count)
+void _glfwPollMonitorsEGLDevice(void)
{
- _GLFWmonitor** monitors;
- _GLFWmonitor* monitor;
- int monitorsCount = 1;
+ _GLFWmonitor* monitor = _glfwAllocMonitor("Monitor", 0, 0);
- monitors = calloc(monitorsCount, sizeof(_GLFWmonitor*));
- monitor = calloc(1, sizeof(_GLFWmonitor));
-
- *count = 1;
// Obtain DRM resource info
if (!initDRMResources(monitor, _glfw.egldevice.drmFd))
- return GLFW_FALSE;
+ {
+ _glfwFreeMonitor(monitor);
+ return;
+ }
- monitors[0] = monitor;
-
- return monitors;
-}
-
-GLFWbool _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second)
-{
- _glfwInputError(GLFW_PLATFORM_ERROR,
- "EGLDevice: _glfwPlatformIsSameMonitor not implemented");
- return 0;
+ _glfwInputMonitor(monitor, GLFW_CONNECTED, _GLFW_INSERT_FIRST);
}
void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos)
diff --git a/src/egldevice_platform.h b/src/egldevice_platform.h
index 39ce285..0fdfe6b 100644
--- a/src/egldevice_platform.h
+++ b/src/egldevice_platform.h
@@ -43,18 +43,40 @@
#include <math.h>
#include <stdbool.h>
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-
#include <dlfcn.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <drm_fourcc.h>
+
#include "posix_time.h"
#include "linux_joystick.h"
-#include "posix_tls.h"
-
+#include "posix_thread.h"
#include "egl_context.h"
+#include "osmesa_context.h"
+
+#define EGL_NO_DEVICE_EXT ((EGLDeviceEXT) 0)
+#define EGL_DRM_DEVICE_FILE_EXT 0x3233
+#define EGL_PLATFORM_DEVICE_EXT 0x313f
+#define EGL_DRM_MASTER_FD_EXT 0x333c
+#define EGL_STREAM_FIFO_LENGTH_KHR 0x31fc
+#define EGL_DRM_CRTC_EXT 0x3234
+#define EGL_NO_STREAM_KHR ((EGLStreamKHR) 0)
+#define EGL_STREAM_BIT_KHR 0x0800
+
+typedef void* EGLOutputLayerEXT;
+typedef void* EGLStreamKHR;
+typedef void* EGLDeviceEXT;
+
+typedef EGLBoolean (EGLAPIENTRY * PFNEGLQUERYDEVICESEXTPROC)(EGLint,EGLDeviceEXT*,EGLint*);
+typedef const char *(EGLAPIENTRY * PFNEGLQUERYDEVICESTRINGEXTPROC)(EGLDeviceEXT,EGLint);
+typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
+typedef EGLBoolean (EGLAPIENTRY * PFNEGLGETOUTPUTLAYERSEXTPROC)(EGLDisplay,const EGLAttrib*,EGLOutputLayerEXT*,EGLint,EGLint*);
+typedef EGLStreamKHR (EGLAPIENTRY * PFNEGLCREATESTREAMKHRPROC)(EGLDisplay,const EGLint*);
+typedef EGLBoolean (EGLAPIENTRY * PFNEGLDESTROYSTREAMKHRPROC)(EGLDisplay,EGLStreamKHR);
+typedef EGLBoolean (EGLAPIENTRY * PFNEGLSTREAMCONSUMEROUTPUTEXTPROC)(EGLDisplay,EGLStreamKHR,EGLOutputLayerEXT);
+typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC)(EGLDisplay,EGLConfig,EGLStreamKHR,const EGLint*);
+typedef EGLBoolean (EGLAPIENTRY * PFNEGLSTREAMATTRIBKHRPROC)(EGLDisplay,EGLStreamKHR,EGLenum,EGLint);
+typedef EGLBoolean (EGLAPIENTRY * PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC)(EGLDisplay,EGLStreamKHR,const EGLAttrib*);
#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
#define _glfw_dlclose(handle) dlclose(handle)
@@ -101,7 +123,7 @@
PFNEGLSTREAMCONSUMEROUTPUTEXTPROC eglStreamConsumerOutputEXT;
PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC eglCreateStreamProducerSurfaceKHR;
PFNEGLSTREAMATTRIBKHRPROC eglStreamAttribKHR;
- PFNEGLSTREAMCONSUMERACQUIREATTRIBEXTPROC eglStreamConsumerAcquireAttribEXT;
+ PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC eglStreamConsumerAcquireAttribKHR;
} _GLFWlibraryEgldevice;
// EGLDEVICE-specific per-monitor data
@@ -116,4 +138,6 @@
typedef struct _GLFWcursorEgldevice {
} _GLFWcursorEgldevice;
+void _glfwPollMonitorsEGLDevice(void);
+
#endif // _glfw3_egldevice_platform_h_
diff --git a/src/egldevice_window.c b/src/egldevice_window.c
index 71255df..55b4d5c 100644
--- a/src/egldevice_window.c
+++ b/src/egldevice_window.c
@@ -222,6 +222,30 @@
"EGLDevice: _glfwPlatformMaximizeWindow not implemented");
}
+void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGLDevice: _glfwPlatformSetWindowResizable not implemented");
+}
+
+void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGLDevice: _glfwPlatformSetWindowDecorated not implemented");
+}
+
+void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGLDevice: _glfwPlatformSetWindowFloating not implemented");
+}
+
+void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGLDevice: _glfwPlatformRequestWindowAttention not implemented");
+}
+
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
return;
@@ -369,11 +393,24 @@
return NULL;
}
-char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count)
+const char* _glfwPlatformGetScancodeName(int scancode)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGLDevice: _glfwPlatformGetScancodeName not supported");
+ return "";
+}
+
+int _glfwPlatformGetKeyScancode(int key)
+{
+ _glfwInputError(GLFW_PLATFORM_ERROR,
+ "EGLDevice: _glfwPlatformGetKeyScancode not supported");
+ return -1;
+}
+
+void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGLDevice: _glfwPlatformGetRequiredInstanceExtensions not supported");
- return NULL;
}
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,