diff --git a/glfw/cocoa_platform.h b/glfw/cocoa_platform.h index ed6305170..f2a218ec5 100644 --- a/glfw/cocoa_platform.h +++ b/glfw/cocoa_platform.h @@ -103,9 +103,6 @@ typedef VkResult (APIENTRY *PFN_vkCreateMetalSurfaceEXT)(VkInstance,const VkMeta #define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlsym(handle, name) dlsym(handle, name) -#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.layer) -#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerNS ns diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index f32663600..f5c37d452 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -2105,6 +2105,16 @@ const char* _glfwPlatformGetClipboardString(void) return _glfw.ns.clipboardString; } +EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +{ + return EGL_DEFAULT_DISPLAY; +} + +EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +{ + return window->ns.layer; +} + void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) { if (_glfw.vk.KHR_surface && _glfw.vk.EXT_metal_surface) diff --git a/glfw/egl_context.c b/glfw/egl_context.c index 82333db5c..26ff7be0f 100644 --- a/glfw/egl_context.c +++ b/glfw/egl_context.c @@ -351,7 +351,7 @@ bool _glfwInitEGL(void) return false; } - _glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY); + _glfw.egl.display = eglGetDisplay(_glfwPlatformGetEGLNativeDisplay()); if (_glfw.egl.display == EGL_NO_DISPLAY) { _glfwInputError(GLFW_API_UNAVAILABLE, @@ -557,7 +557,7 @@ bool _glfwCreateContextEGL(_GLFWwindow* window, window->context.egl.surface = eglCreateWindowSurface(_glfw.egl.display, config, - _GLFW_EGL_NATIVE_WINDOW, + _glfwPlatformGetEGLNativeWindow(window), attribs); if (window->context.egl.surface == EGL_NO_SURFACE) { diff --git a/glfw/egl_context.h b/glfw/egl_context.h index 362de2fe0..965dc53c2 100644 --- a/glfw/egl_context.h +++ b/glfw/egl_context.h @@ -25,26 +25,10 @@ // //======================================================================== -#if defined(_GLFW_USE_EGLPLATFORM_H) - #include -#elif defined(_GLFW_WIN32) +#if defined(_GLFW_WIN32) #define EGLAPIENTRY __stdcall -typedef HDC EGLNativeDisplayType; -typedef HWND EGLNativeWindowType; -#elif defined(_GLFW_COCOA) - #define EGLAPIENTRY -typedef void* EGLNativeDisplayType; -typedef id EGLNativeWindowType; -#elif defined(_GLFW_X11) - #define EGLAPIENTRY -typedef Display* EGLNativeDisplayType; -typedef Window EGLNativeWindowType; -#elif defined(_GLFW_WAYLAND) - #define EGLAPIENTRY -typedef struct wl_display* EGLNativeDisplayType; -typedef struct wl_egl_window* EGLNativeWindowType; #else - #error "No supported EGL platform selected" + #define EGLAPIENTRY #endif #define EGL_SUCCESS 0x3000 @@ -117,6 +101,9 @@ typedef void* EGLContext; typedef void* EGLDisplay; typedef void* EGLSurface; +typedef void* EGLNativeDisplayType; +typedef void* EGLNativeWindowType; + // EGL function pointer typedefs typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); diff --git a/glfw/internal.h b/glfw/internal.h index b6ff86f62..bbc7696c1 100644 --- a/glfw/internal.h +++ b/glfw/internal.h @@ -721,6 +721,9 @@ void _glfwPlatformWaitEvents(void); void _glfwPlatformWaitEventsTimeout(monotonic_t timeout); void _glfwPlatformPostEmptyEvent(void); +EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void); +EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window); + void _glfwPlatformGetRequiredInstanceExtensions(char** extensions); int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, diff --git a/glfw/null_platform.h b/glfw/null_platform.h index d767e87b8..d03a83877 100644 --- a/glfw/null_platform.h +++ b/glfw/null_platform.h @@ -34,9 +34,8 @@ #define _GLFW_PLATFORM_CONTEXT_STATE #define _GLFW_PLATFORM_CURSOR_STATE #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE -#define _GLFW_EGL_CONTEXT_STATE -#define _GLFW_EGL_LIBRARY_CONTEXT_STATE +#include "egl_context.h" #include "osmesa_context.h" #include "posix_time.h" #include "posix_thread.h" diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index 6d3d26ff3..9a00ef3de 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -66,9 +66,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR #define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlsym(handle, name) dlsym(handle, name) -#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->wl.native) -#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.wl.display) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 085d175b4..df0dcf1cd 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -2008,6 +2008,16 @@ const char* _glfwPlatformGetPrimarySelectionString(void) return NULL; } +EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +{ + return _glfw.wl.display; +} + +EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +{ + return window->wl.native; +} + void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) { if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_wayland_surface) diff --git a/glfw/x11_platform.h b/glfw/x11_platform.h index 6f59101bc..923b84dd1 100644 --- a/glfw/x11_platform.h +++ b/glfw/x11_platform.h @@ -165,9 +165,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(Vk #define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlsym(handle, name) dlsym(handle, name) -#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->x11.handle) -#define _GLFW_EGL_NATIVE_DISPLAY ((EGLNativeDisplayType) _glfw.x11.display) - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11 #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11 diff --git a/glfw/x11_window.c b/glfw/x11_window.c index b28ee7a3e..adde3eedf 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -2855,6 +2855,16 @@ const char* _glfwPlatformGetPrimarySelectionString(void) return getSelectionString(_glfw.x11.PRIMARY); } +EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +{ + return _glfw.x11.display; +} + +EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +{ + return (EGLNativeWindowType) window->x11.handle; +} + void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) { if (!_glfw.vk.KHR_surface)