diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dd50d8d7..43e88953 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,10 +7,10 @@ set(common_SOURCES context.c init.c input.c monitor.c vulkan.c window.c) if (_GLFW_COCOA) set(glfw_HEADERS ${common_HEADERS} cocoa_platform.h cocoa_joystick.h - posix_tls.h nsgl_context.h) + posix_tls.h nsgl_context.h egl_context.h) set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_joystick.m cocoa_monitor.m cocoa_window.m cocoa_time.c posix_tls.c - nsgl_context.m) + nsgl_context.m egl_context.c) elseif (_GLFW_WIN32) set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_joystick.h wgl_context.h egl_context.h) diff --git a/src/cocoa_platform.h b/src/cocoa_platform.h index f6e357a8..6498619b 100644 --- a/src/cocoa_platform.h +++ b/src/cocoa_platform.h @@ -54,20 +54,21 @@ typedef VkResult (APIENTRY *PFN_vkCreateMacOSSurfaceMVK)(VkInstance,const VkMacO #include "posix_tls.h" #include "cocoa_joystick.h" #include "nsgl_context.h" +#include "egl_context.h" #define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL) #define _glfw_dlclose(handle) dlclose(handle) #define _glfw_dlsym(handle, name) dlsym(handle, name) +#define _GLFW_EGL_NATIVE_WINDOW ((EGLNativeWindowType) window->ns.view) +#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_TIME_STATE _GLFWtimeNS ns_time #define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns #define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorNS ns -#define _GLFW_EGL_CONTEXT_STATE -#define _GLFW_EGL_LIBRARY_CONTEXT_STATE - // HIToolbox.framework pointer typedefs #define kTISPropertyUnicodeKeyLayoutData _glfw.ns.tis.kPropertyUnicodeKeyLayoutData typedef TISInputSourceRef (*PFN_TISCopyCurrentKeyboardLayoutInputSource)(void); diff --git a/src/cocoa_window.m b/src/cocoa_window.m index ef46279b..4b48d85b 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1082,8 +1082,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, } else { - _glfwInputError(GLFW_API_UNAVAILABLE, "Cocoa: EGL not available"); - return GLFW_FALSE; + if (!_glfwInitEGL()) + return GLFW_FALSE; + if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) + return GLFW_FALSE; } } diff --git a/src/egl_context.h b/src/egl_context.h index 219a6c51..e1040acd 100644 --- a/src/egl_context.h +++ b/src/egl_context.h @@ -34,6 +34,10 @@ #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;