From d376e06aa16653a1e5cc82d38f416a67bf920940 Mon Sep 17 00:00:00 2001 From: knokko Date: Sun, 27 Jun 2021 17:36:01 +0200 Subject: [PATCH 1/3] Add glfwGetGLXFBConfig This commit adds a new function called glfwGetGLXFBConfig that will return the GLXFBConfig that was chosen to create a given window. --- README.md | 1 + include/GLFW/glfw3native.h | 15 +++++++++++++++ src/glx_context.c | 20 ++++++++++++++++++++ src/glx_context.h | 1 + 4 files changed, 37 insertions(+) diff --git a/README.md b/README.md index 0be9d388..761db17b 100644 --- a/README.md +++ b/README.md @@ -243,6 +243,7 @@ information on what to include when reporting a bug. - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension (#1380) - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) + - [GLX] Made it possible to query the `GLXFBConfig` that was chosen to create a given window via `glfwGetGLXFBConfig` ## Contact diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 06021ef9..03d2b4db 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -385,6 +385,21 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window); * @ingroup native */ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); + +/*! @brief Returns the `GLXFBConfig` that was chosen to create the + * specified window. + * + * @return The `GLXFBConfig` that was chosen to create the specified + * window, or `NULL` if an [error](@ref error_handling) occurred. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @since Added in version 3.3.5 + * + * @ingroup native + */ +GLFWAPI GLXFBConfig glfwGetGLXFBConfig(GLFWwindow* window); #endif #if defined(GLFW_EXPOSE_NATIVE_WAYLAND) diff --git a/src/glx_context.c b/src/glx_context.c index 374c15e0..86355f20 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -242,6 +242,11 @@ static void destroyContextGLX(_GLFWwindow* window) glXDestroyContext(_glfw.x11.display, window->context.glx.handle); window->context.glx.handle = NULL; } + + if (window->context.glx.fbConfig) + { + window->context.glx.fbConfig = NULL; + } } @@ -620,6 +625,8 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, return GLFW_FALSE; } + window->context.glx.fbConfig = native; + window->context.makeCurrent = makeContextCurrentGLX; window->context.swapBuffers = swapBuffersGLX; window->context.swapInterval = swapIntervalGLX; @@ -697,3 +704,16 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) return window->context.glx.window; } +GLFWAPI GLXFBConfig glfwGetGLXFBConfig(GLFWwindow* handle) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(None); + + if (window->context.client == GLFW_NO_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return NULL; + } + + return window->context.glx.fbConfig; +} diff --git a/src/glx_context.h b/src/glx_context.h index 94f07e2e..73cc74c5 100644 --- a/src/glx_context.h +++ b/src/glx_context.h @@ -117,6 +117,7 @@ typedef struct _GLFWcontextGLX { GLXContext handle; GLXWindow window; + GLXFBConfig fbConfig; } _GLFWcontextGLX; From 53f62d040497ba270e2352b178f2068eef9f0d23 Mon Sep 17 00:00:00 2001 From: knokko Date: Sun, 27 Jun 2021 18:48:57 +0200 Subject: [PATCH 2/3] Add a news entry for glfwGetGLXFBConfig --- docs/news.dox | 11 +++++++++++ include/GLFW/glfw3native.h | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/news.dox b/docs/news.dox index d9ed0b1d..e9c29714 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -53,6 +53,13 @@ Alt-and-then-Space shortcuts. This may be useful for more GUI-oriented applications. +@subsubsection features_34_glx_getfbconfig Query GLXFBConfig + +GLFW now provides the [glfwGetGLXFBConfig](@ref glfwGetGLXFBConfig) +function that returns the GLXFBConfig that was chosen to create the +given window handle. + + @subsection caveats_34 Caveats for version 3.4 @subsubsection joysticks_34 Joystick support is initialized on demand @@ -118,6 +125,10 @@ then GLFW will fail to initialize. @subsection symbols_34 New symbols in version 3.4 @subsubsection functions_34 New functions in version 3.4 + + - @ref glfwGetGLXFBConfig + + @subsubsection types_34 New types in version 3.4 @subsubsection constants_34 New constants in version 3.4 diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 03d2b4db..0321a36a 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -395,7 +395,7 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); * @thread_safety This function may be called from any thread. Access is not * synchronized. * - * @since Added in version 3.3.5 + * @since Added in version 3.4 * * @ingroup native */ From d9f723fbbff0fbe5ce8968007dc2bbf1d891ab2f Mon Sep 17 00:00:00 2001 From: knokko Date: Wed, 2 Feb 2022 21:04:35 +0100 Subject: [PATCH 3/3] EGL: Add glfwGetEGLConfig --- README.md | 1 + docs/news.dox | 7 +++++++ include/GLFW/glfw3native.h | 17 +++++++++++++++++ src/egl_context.c | 13 +++++++++++++ 4 files changed, 38 insertions(+) diff --git a/README.md b/README.md index fe222f27..8713fe65 100644 --- a/README.md +++ b/README.md @@ -303,6 +303,7 @@ information on what to include when reporting a bug. - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension (#1380) - [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) + - [EGL] Made it possible to query the `EGLConfig` that was chosen to create a given window via `glfwGetEGLConfig` - [GLX] Made it possible to query the `GLXFBConfig` that was chosen to create a given window via `glfwGetGLXFBConfig` diff --git a/docs/news.dox b/docs/news.dox index decd888d..3f4fdd05 100644 --- a/docs/news.dox +++ b/docs/news.dox @@ -77,6 +77,12 @@ GLFW now provides the [glfwGetGLXFBConfig](@ref glfwGetGLXFBConfig) function that returns the GLXFBConfig that was chosen to create the given window handle. +@subsubsection features_34_egl_getconfig Query EGLConfig + +GLFW now provides the [glfwGetEGLConfig](@ref glfwGetEGLConfig) +function that returns the EGLConfig that was chosen to create the +given window handle. + @subsection caveats_34 Caveats for version 3.4 @subsection caveats Caveats for version 3.4 @@ -185,6 +191,7 @@ then GLFW will fail to initialize. @subsubsection functions_34 New functions in version 3.4 - @ref glfwGetGLXFBConfig + - @ref glfwGetEGLConfig - @ref glfwInitAllocator - @ref glfwGetPlatform - @ref glfwPlatformSupported diff --git a/include/GLFW/glfw3native.h b/include/GLFW/glfw3native.h index 334dabf0..f886e60b 100644 --- a/include/GLFW/glfw3native.h +++ b/include/GLFW/glfw3native.h @@ -532,6 +532,23 @@ GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window); * @ingroup native */ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window); + +/*! @brief Returns the `EGLConfig` of the specified window. + * + * @return The `EGLConfig` of the specified window, or `EGL_NO_SURFACE` if an + * [error](@ref error_handling) occurred. + * + * @errors Possible errors include @ref GLFW_NO_WINDOW_CONTEXT and @ref + * GLFW_NOT_INITIALIZED. + * + * @thread_safety This function may be called from any thread. Access is not + * synchronized. + * + * @since Added in version 3.0. + * + * @ingroup native + */ +GLFWAPI EGLConfig glfwGetEGLConfig(GLFWwindow* window); #endif #if defined(GLFW_EXPOSE_NATIVE_OSMESA) diff --git a/src/egl_context.c b/src/egl_context.c index 89ea78fa..502e488e 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -866,3 +866,16 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) return window->context.egl.surface; } +GLFWAPI EGLConfig glfwGetEGLConfig(GLFWwindow* handle) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + _GLFW_REQUIRE_INIT_OR_RETURN(EGL_NO_SURFACE); + + if (window->context.source != GLFW_EGL_CONTEXT_API) + { + _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); + return EGL_NO_SURFACE; + } + + return window->context.egl.config; +}