add filtering of pixelformat composition for win32 transparent window

This commit is contained in:
Christopher Pelloux 2016-03-01 15:41:47 -05:00
parent 5796b966bf
commit 25313317f0

View File

@ -133,6 +133,20 @@ static GLFWbool choosePixelFormat(_GLFWwindow* window,
{ {
const int n = i + 1; const int n = i + 1;
_GLFWfbconfig* u = usableConfigs + usableCount; _GLFWfbconfig* u = usableConfigs + usableCount;
PIXELFORMATDESCRIPTOR pfd;
if (window->transparent) {
if (!DescribePixelFormat(window->context.wgl.dc,
n,
sizeof(PIXELFORMATDESCRIPTOR),
&pfd))
{
continue;
}
if (!(pfd.dwFlags & PFD_SUPPORT_COMPOSITION))
continue;
}
if (_glfw.wgl.ARB_pixel_format) if (_glfw.wgl.ARB_pixel_format)
{ {
@ -188,11 +202,9 @@ static GLFWbool choosePixelFormat(_GLFWwindow* window,
} }
else else
{ {
PIXELFORMATDESCRIPTOR pfd;
// Get pixel format attributes through legacy PFDs // Get pixel format attributes through legacy PFDs
if (!DescribePixelFormat(window->context.wgl.dc, if (!window->transparent && !DescribePixelFormat(window->context.wgl.dc,
n, n,
sizeof(PIXELFORMATDESCRIPTOR), sizeof(PIXELFORMATDESCRIPTOR),
&pfd)) &pfd))
@ -239,6 +251,13 @@ static GLFWbool choosePixelFormat(_GLFWwindow* window,
u->wgl = n; u->wgl = n;
usableCount++; usableCount++;
} }
// Reiterate the selection loop without looking for transparency supporting
// formats if no matching pixelformat for a transparent window were found.
if (window->transparent && !usableCount) {
window->transparent = GLFW_FALSE;
free(usableConfigs);
return choosePixelFormat(window, desired, result);
}
if (!usableCount) if (!usableCount)
{ {