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.
This commit is contained in:
Bailey Cosier 2017-09-21 12:43:39 +07:00
parent 3b5d58cc46
commit 349f06d632
3 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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: