From 349f06d6321bc00ec5b44f84007f5691ee6b1314 Mon Sep 17 00:00:00 2001 From: Bailey Cosier Date: Thu, 21 Sep 2017 12:43:39 +0700 Subject: [PATCH] Add ability to check GLFW_TRANSPARENT hint outcome with `glfwGetWindowAttrib()` To make this possible, in situations where GLFW_TRANSPARENT is requested but failed to match with a FBConfig, the internal framebufer hint is set to GLFW_FALSE. glfwGetWindowAttrib() then relies on the internal `_glfw.framebuffer.hint.transparent` bool. --- docs/window.dox | 4 +++- src/context.c | 6 ++++++ src/window.c | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/window.dox b/docs/window.dox index 37debd6ee..8c637f655 100644 --- a/docs/window.dox +++ b/docs/window.dox @@ -289,7 +289,9 @@ constraint. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. @anchor GLFW_TRANSPARENT __GLFW_TRANSPARENT__ specifies whether the framebuffer will support transparency -in the background. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. +in the background. If transparency is not provided by your driver, GLFW will +gracefully fallback to opaque. It is possible to check for this outcome +with `glfwGetWindowAttrib()`. Possible values are `GLFW_TRUE` and `GLFW_FALSE`. @subsubsection window_hints_mtr Monitor related hints diff --git a/src/context.c b/src/context.c index 3842f0a37..3c0d5e657 100644 --- a/src/context.c +++ b/src/context.c @@ -318,6 +318,12 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, } } + if (desired->transparent && closest->transparent != GLFW_TRUE) + { + // If we couldn't find a transparency match, + // update the fb hint for client checking. + _glfw.hints.framebuffer.transparent = GLFW_FALSE; + } return closest; } diff --git a/src/window.c b/src/window.c index 863f0ed23..3b53477c1 100644 --- a/src/window.c +++ b/src/window.c @@ -732,6 +732,8 @@ GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib) return window->resizable; case GLFW_DECORATED: return window->decorated; + case GLFW_TRANSPARENT: + return _glfw.hints.framebuffer.transparent; case GLFW_FLOATING: return window->floating; case GLFW_AUTO_ICONIFY: