mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 00:30:57 +00:00
Add glfwGetWindowOpacity and glfwSetWindowOpacity
This adds support for setting the opacity of the whole window, including any decorations. Fixes #1089.
This commit is contained in:
+8
-3
@@ -94,12 +94,17 @@ be disabled with the @ref GLFW_JOYSTICK_HAT_BUTTONS init hint.
|
||||
@see @ref joystick_hat
|
||||
|
||||
|
||||
@subsection news_33_transparent Support for transparent window framebuffer
|
||||
@subsection news_33_transparent Support for transparent windows and framebuffers
|
||||
|
||||
GLFW now supports the creation of windows with transparent framebuffers on
|
||||
systems with desktop compositing enabled with the @ref
|
||||
GLFW_TRANSPARENT_FRAMEBUFFER window hint and attribute. Any window decorations
|
||||
will still be opaque.
|
||||
GLFW_TRANSPARENT_FRAMEBUFFER window hint and attribute. This hint must be set
|
||||
before window creation and leaves any window decorations opaque.
|
||||
|
||||
GLFW now also supports whole window transparency with @ref glfwGetWindowOpacity
|
||||
and @ref glfwSetWindowOpacity. This value controls the opacity of the whole
|
||||
window including decorations and unlike framebuffer transparency can be changed
|
||||
at any time after window creation.
|
||||
|
||||
|
||||
@subsection news_33_centercursor Cursor centering window hint
|
||||
|
||||
@@ -1091,6 +1091,14 @@ the window or framebuffer is resized.
|
||||
|
||||
@subsection window_transparency Window transparency
|
||||
|
||||
GLFW supports two kinds of transparency for windows; framebuffer transparency
|
||||
and whole window transparency. A single window may not use both methods. The
|
||||
results of doing this are undefined.
|
||||
|
||||
Both methods require the platform to support it and not every version of every
|
||||
platform GLFW supports does this, so there are mechanisms to check whether the
|
||||
window really is transparent.
|
||||
|
||||
Window framebuffers can be made transparent on a per-pixel per-frame basis with
|
||||
the [GLFW_TRANSPARENT_FRAMEBUFFER](@ref GLFW_TRANSPARENT_FRAMEBUFFER_hint)
|
||||
window hint.
|
||||
@@ -1115,6 +1123,31 @@ if (glfwGetWindowAttrib(window, GLFW_TRANSPARENT_FRAMEBUFFER))
|
||||
}
|
||||
@endcode
|
||||
|
||||
GLFW comes with an example that enabled framebuffer transparency called `gears`.
|
||||
|
||||
The opacity of the whole window, including any decorations, can be set with @ref
|
||||
glfwSetWindowOpacity.
|
||||
|
||||
@code
|
||||
glfwSetWindowOpacity(window, 0.5f);
|
||||
@endcode
|
||||
|
||||
The opacity (or alpha) value is a positive finite number between zero and one,
|
||||
where 0 (zero) is fully transparent and 1 (one) is fully opaque. The initial
|
||||
opacity value for newly created windows is 1.
|
||||
|
||||
The current opacity of a window can be queried with @ref glfwGetWindowOpacity.
|
||||
|
||||
@code
|
||||
float opacity = glfwGetWindowOpacity(window);
|
||||
@endcode
|
||||
|
||||
If the system does not support whole window transparency, this function always
|
||||
returns one.
|
||||
|
||||
GLFW comes with a test program that lets you control whole window transparency
|
||||
at run-time called `opacity`.
|
||||
|
||||
|
||||
@subsection window_attribs Window attributes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user