From d0776e04a34bbdfcc78c7bbad8fe0425c6380035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 14 Jul 2021 20:06:22 +0200 Subject: [PATCH] Null: Add non-functional EGL support This is done in preparation for runtime platform selection, to make sure every platform can build with EGL enabled. It may be possible to add support for things like the ANGLE null platform later. --- src/CMakeLists.txt | 3 ++- src/null_init.c | 3 ++- src/null_window.c | 23 ++++++++++++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf358996..2b6e6243 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,7 +48,8 @@ elseif (_GLFW_OSMESA) target_sources(glfw PRIVATE null_platform.h null_joystick.h posix_time.h posix_thread.h osmesa_context.h null_init.c null_monitor.c null_window.c null_joystick.c - posix_time.c posix_thread.c osmesa_context.c) + posix_time.c posix_thread.c egl_context.c + osmesa_context.c) endif() if (_GLFW_X11 OR _GLFW_WAYLAND) diff --git a/src/null_init.c b/src/null_init.c index 68599d1f..d72b06bf 100644 --- a/src/null_init.c +++ b/src/null_init.c @@ -48,10 +48,11 @@ void _glfwPlatformTerminate(void) { _glfw_free(_glfw.null.clipboardString); _glfwTerminateOSMesa(); + _glfwTerminateEGL(); } const char* _glfwPlatformGetVersionString(void) { - return _GLFW_VERSION_NUMBER " null OSMesa"; + return _GLFW_VERSION_NUMBER " null OSMesa EGL"; } diff --git a/src/null_window.c b/src/null_window.c index 1f59540e..6a251153 100644 --- a/src/null_window.c +++ b/src/null_window.c @@ -121,10 +121,12 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig)) return GLFW_FALSE; } - else + else if (ctxconfig->source == GLFW_EGL_CONTEXT_API) { - _glfwInputError(GLFW_API_UNAVAILABLE, "Null: EGL not available"); - return GLFW_FALSE; + if (!_glfwInitEGL()) + return GLFW_FALSE; + if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig)) + return GLFW_FALSE; } } @@ -522,6 +524,21 @@ const char* _glfwPlatformGetClipboardString(void) return _glfw.null.clipboardString; } +EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs) +{ + return 0; +} + +EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void) +{ + return 0; +} + +EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window) +{ + return 0; +} + const char* _glfwPlatformGetScancodeName(int scancode) { if (scancode < GLFW_KEY_SPACE || scancode > GLFW_KEY_LAST)