Add glfwGetGLXFBConfig

This commit adds a new function called glfwGetGLXFBConfig that
will return the GLXFBConfig that was chosen to create a given
window.
This commit is contained in:
knokko 2021-06-27 17:36:01 +02:00
parent 6876cf8d7e
commit d376e06aa1
4 changed files with 37 additions and 0 deletions

View File

@ -243,6 +243,7 @@ information on what to include when reporting a bug.
- [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension - [EGL] Added ANGLE backend selection via `EGL_ANGLE_platform_angle` extension
(#1380) (#1380)
- [EGL] Bugfix: The `GLFW_DOUBLEBUFFER` context attribute was ignored (#1843) - [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 ## Contact

View File

@ -385,6 +385,21 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
* @ingroup native * @ingroup native
*/ */
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window); 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 #endif
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND) #if defined(GLFW_EXPOSE_NATIVE_WAYLAND)

View File

@ -242,6 +242,11 @@ static void destroyContextGLX(_GLFWwindow* window)
glXDestroyContext(_glfw.x11.display, window->context.glx.handle); glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
window->context.glx.handle = NULL; 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; return GLFW_FALSE;
} }
window->context.glx.fbConfig = native;
window->context.makeCurrent = makeContextCurrentGLX; window->context.makeCurrent = makeContextCurrentGLX;
window->context.swapBuffers = swapBuffersGLX; window->context.swapBuffers = swapBuffersGLX;
window->context.swapInterval = swapIntervalGLX; window->context.swapInterval = swapIntervalGLX;
@ -697,3 +704,16 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
return window->context.glx.window; 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;
}

View File

@ -117,6 +117,7 @@ typedef struct _GLFWcontextGLX
{ {
GLXContext handle; GLXContext handle;
GLXWindow window; GLXWindow window;
GLXFBConfig fbConfig;
} _GLFWcontextGLX; } _GLFWcontextGLX;