Transparency on X11 via more precise FBConfig selection

This commit is contained in:
Bailey Cosier 2017-09-16 17:09:09 +07:00
parent a5e83e59fa
commit 2fbb5268da
2 changed files with 13 additions and 3 deletions

View File

@ -241,7 +241,12 @@ if (_GLFW_X11)
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS "${X11_X11_INCLUDE_PATH}")
list(APPEND glfw_LIBRARIES "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
list(APPEND glfw_LIBRARIES "${X11_Xrender_LIB}" "${X11_X11_LIB}" "${CMAKE_THREAD_LIBS_INIT}")
# Check for XRender (image composition and pict format querying)
if (NOT X11_Xrender_FOUND)
message(FATAL_ERROR "The XRender headers were not found")
endif()
# Check for XRandR (modern resolution switching and gamma control)
if (NOT X11_Xrandr_FOUND)

View File

@ -55,6 +55,8 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* res
int i, nativeCount, usableCount;
const char* vendor;
GLFWbool trustWindowBit = GLFW_TRUE;
XVisualInfo *visual;
XRenderPictFormat *pict_format;
// HACK: This is a (hopefully temporary) workaround for Chromium
// (VirtualBox GL) not setting the window bit on any GLXFBConfigs
@ -64,6 +66,7 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* res
nativeConfigs =
glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
if (!nativeConfigs || !nativeCount)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
@ -89,6 +92,10 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* res
continue;
}
visual = glXGetVisualFromFBConfig(_glfw.x11.display, n);
pict_format = XRenderFindVisualFormat(_glfw.x11.display, visual->visual);
u->alphaMask = pict_format->direct.alphaMask > 0;
u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
@ -97,8 +104,6 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* res
u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
u->alphaMask = getGLXFBConfigAttrib(n, GLX_RGBA);
u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);