From 1d44ad152e8f7efa0b7b8742e227a20b046150f3 Mon Sep 17 00:00:00 2001 From: Bailey Cosier Date: Sun, 17 Sep 2017 00:49:42 +0700 Subject: [PATCH] Renaming alphaMask flag to 'transparent' for consistency --- src/context.c | 6 ------ src/egl_context.c | 4 ++-- src/glx_context.c | 35 +++++++++++++++++++++-------------- src/internal.h | 3 +-- src/wgl_context.c | 6 ++++-- src/window.c | 9 ++++----- 6 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/context.c b/src/context.c index 4c52d3da1..1a26356e1 100644 --- a/src/context.c +++ b/src/context.c @@ -182,12 +182,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, continue; } - if (desired->alphaMask > 0 && current->alphaMask == 0) - { - // Alpha mask is a hard constraint - continue; - } - // Count number of missing buffers { missing = 0; diff --git a/src/egl_context.c b/src/egl_context.c index 820407e97..8c0fae1c4 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -492,7 +492,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (ctxconfig->share) share = ctxconfig->share->context.egl.handle; - if (!chooseEGLConfig(ctxconfig, fbconfig, &config, fbconfig->alphaMask)) + if (!chooseEGLConfig(ctxconfig, fbconfig, &config, fbconfig->transparent)) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Failed to find a suitable EGLConfig"); @@ -738,7 +738,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, const long vimask = VisualScreenMask | VisualIDMask; - if (!chooseEGLConfig(ctxconfig, fbconfig, &native, wndconfig->alphaMask)) + if (!chooseEGLConfig(ctxconfig, fbconfig, &native, wndconfig->transparent)) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Failed to find a suitable EGLConfig"); diff --git a/src/glx_context.c b/src/glx_context.c index 546321826..6a82463f4 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -64,6 +64,8 @@ static GLFWbool chooseGLXFBConfig( findTransparent = GLFW_FALSE; } + findTransparent = GLFW_TRUE; + // HACK: This is a (hopefully temporary) workaround for Chromium // (VirtualBox GL) not setting the window bit on any GLXFBConfigs vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR); @@ -81,7 +83,7 @@ static GLFWbool chooseGLXFBConfig( usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); usableCount = 0; - + selectionloop: for (i = 0; i < nativeCount; i++) { @@ -99,25 +101,31 @@ selectionloop: continue; } - if( findTransparent ) { + if( findTransparent ) { XVisualInfo *visualinfo; XRenderPictFormat *pictFormat; - visualinfo = glXGetVisualFromFBConfig(_glfw.x11.display, n); - if (!visualinfo) - continue; + visualinfo = glXGetVisualFromFBConfig(_glfw.x11.display, n); + if (!visualinfo) { + printf("!visualinfo: bail\n"); + continue; + } pictFormat = XRenderFindVisualFormat(_glfw.x11.display, visualinfo->visual); if( !pictFormat ) { - XFree( visualinfo ); - continue; - } + printf("!pictFormat: bail\n"); + XFree( visualinfo ); + continue; + } if( !pictFormat->direct.alphaMask ) { - XFree( visualinfo ); - continue; - } - XFree( visualinfo ); + printf("!pictFormat->direct alphaMask: bail\n"); + XFree( visualinfo ); + continue; + } + + printf("looking for transparent visual: didn't find\n"); + XFree( visualinfo ); } u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE); @@ -150,7 +158,7 @@ selectionloop: usableCount++; } // reiterate the selection loop without looking for transparency supporting - // formats if no matchig FB configs for a transparent window were found. + // formats if no matchig FB configs for a transparent window were found. if( findTransparent && !usableCount ) { findTransparent = GLFW_FALSE; goto selectionloop; @@ -722,4 +730,3 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle) return window->context.glx.window; } - diff --git a/src/internal.h b/src/internal.h index 826296674..54f8fa355 100644 --- a/src/internal.h +++ b/src/internal.h @@ -305,7 +305,6 @@ struct _GLFWwndconfig GLFWbool floating; GLFWbool maximized; GLFWbool centerCursor; - GLFWbool alphaMask; struct { GLFWbool retina; GLFWbool frame; @@ -349,7 +348,7 @@ struct _GLFWfbconfig int redBits; int greenBits; int blueBits; - int alphaMask; + int transparent; int alphaBits; int depthBits; int stencilBits; diff --git a/src/wgl_context.c b/src/wgl_context.c index 867ecd60d..1be457209 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -213,8 +213,10 @@ static int choosePixelFormat(_GLFWwindow* window, } u->handle = n; - // always able to create alpha mask on win - u->alphaMask = 1; + + // always able to go transparent on win dwmapi + u->transparent = 1; + usableCount++; } // Reiterate the selection loop without looking for transparency supporting diff --git a/src/window.c b/src/window.c index 625e2523b..7ee2b8c97 100644 --- a/src/window.c +++ b/src/window.c @@ -147,13 +147,13 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, fbconfig = _glfw.hints.framebuffer; ctxconfig = _glfw.hints.context; wndconfig = _glfw.hints.window; - fbconfig.alphaMask = _glfw.hints.framebuffer.alphaMask ? GLFW_TRUE : GLFW_FALSE; + fbconfig.transparent = _glfw.hints.framebuffer.transparent ? GLFW_TRUE : GLFW_FALSE; wndconfig.width = width; wndconfig.height = height; wndconfig.title = title; ctxconfig.share = (_GLFWwindow*) share; - wndconfig.alphaMask = _glfw.hints.framebuffer.alphaMask ? GLFW_TRUE : GLFW_FALSE; + wndconfig.transparent = _glfw.hints.framebuffer.transparent ? GLFW_TRUE : GLFW_FALSE; if (ctxconfig.share) { @@ -185,7 +185,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height, window->transparent = wndconfig.transparent; window->autoIconify = wndconfig.autoIconify; window->floating = wndconfig.floating; - window->transparent = wndconfig.alphaMask; window->cursorMode = GLFW_CURSOR_NORMAL; window->minwidth = GLFW_DONT_CARE; @@ -267,7 +266,7 @@ void glfwDefaultWindowHints(void) _glfw.hints.framebuffer.depthBits = 24; _glfw.hints.framebuffer.stencilBits = 8; _glfw.hints.framebuffer.doublebuffer = GLFW_TRUE; - _glfw.hints.framebuffer.alphaMask = GLFW_FALSE; + _glfw.hints.framebuffer.transparent = GLFW_FALSE; // The default is to select the highest available refresh rate _glfw.hints.refreshRate = GLFW_DONT_CARE; @@ -322,7 +321,7 @@ GLFWAPI void glfwWindowHint(int hint, int value) _glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE; return; case GLFW_TRANSPARENT: - _glfw.hints.framebuffer.alphaMask = value; + _glfw.hints.framebuffer.transparent = value; return; case GLFW_SAMPLES: _glfw.hints.framebuffer.samples = value;