diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index b67ddd2b..11c1c9e4 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -92,9 +92,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/src/cocoa_window.m b/src/cocoa_window.m index b7a18cad..ebc747c7 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1721,6 +1721,16 @@ const char* _glfwPlatformGetClipboardString(void) } // autoreleasepool } +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/src/egl_context.c b/src/egl_context.c index 819a2b2d..a167f341 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -395,7 +395,7 @@ GLFWbool _glfwInitEGL(void) return GLFW_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, @@ -601,7 +601,7 @@ GLFWbool _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/src/egl_context.h b/src/egl_context.h index 8bfb7db6..8ad0b1ba 100644 --- a/src/egl_context.h +++ b/src/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 @@ -115,6 +99,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/src/internal.h b/src/internal.h index 6d7587c8..b7ed9659 100644 --- a/src/internal.h +++ b/src/internal.h @@ -681,6 +681,9 @@ void _glfwPlatformWaitEvents(void); void _glfwPlatformWaitEventsTimeout(double timeout); void _glfwPlatformPostEmptyEvent(void); +EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void); +EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window); + void _glfwPlatformGetRequiredInstanceExtensions(char** extensions); int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, diff --git a/src/null_platform.h b/src/null_platform.h index c0995be3..533a746b 100644 --- a/src/null_platform.h +++ b/src/null_platform.h @@ -34,9 +34,8 @@ #define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; } #define _GLFW_PLATFORM_CURSOR_STATE struct { int dummyCursor; } #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; } -#define _GLFW_EGL_CONTEXT_STATE struct { int dummyEGLContext; } -#define _GLFW_EGL_LIBRARY_CONTEXT_STATE struct { int dummyEGLLibraryContext; } +#include "egl_context.h" #include "osmesa_context.h" #include "posix_time.h" #include "posix_thread.h" diff --git a/src/win32_platform.h b/src/win32_platform.h index 9a0b5ad8..9e46335c 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -285,9 +285,6 @@ typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)( #define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle) #define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name) -#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->win32.handle) -#define _GLFW_EGL_NATIVE_DISPLAY EGL_DEFAULT_DISPLAY - #define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32 #define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32 #define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32 diff --git a/src/win32_window.c b/src/win32_window.c index ad72db9c..a55cb7f7 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -2186,6 +2186,16 @@ const char* _glfwPlatformGetClipboardString(void) return _glfw.win32.clipboardString; } +EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +{ + return EGL_DEFAULT_DISPLAY; +} + +EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +{ + return window->win32.handle; +} + void _glfwPlatformGetRequiredInstanceExtensions(char** extensions) { if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface) diff --git a/src/wl_platform.h b/src/wl_platform.h index 542cc78d..4f3e1e59 100644 --- a/src/wl_platform.h +++ b/src/wl_platform.h @@ -67,9 +67,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/src/wl_window.c b/src/wl_window.c index f5d314f3..6e0d2ed7 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -1684,6 +1684,16 @@ const char* _glfwPlatformGetClipboardString(void) return _glfw.wl.clipboardString; } +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/src/x11_platform.h b/src/x11_platform.h index fe82a72b..3257369c 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -373,9 +373,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/src/x11_window.c b/src/x11_window.c index 75f15c6d..3329a66c 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -3048,6 +3048,16 @@ const char* _glfwPlatformGetClipboardString(void) return getSelectionString(_glfw.x11.CLIPBOARD); } +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)