Renaming alphaMask flag to 'transparent' for consistency

This commit is contained in:
Bailey Cosier 2017-09-17 00:49:42 +07:00
parent 98563d8d4b
commit 1d44ad152e
6 changed files with 32 additions and 31 deletions

View File

@ -182,12 +182,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
continue; continue;
} }
if (desired->alphaMask > 0 && current->alphaMask == 0)
{
// Alpha mask is a hard constraint
continue;
}
// Count number of missing buffers // Count number of missing buffers
{ {
missing = 0; missing = 0;

View File

@ -492,7 +492,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
if (ctxconfig->share) if (ctxconfig->share)
share = ctxconfig->share->context.egl.handle; share = ctxconfig->share->context.egl.handle;
if (!chooseEGLConfig(ctxconfig, fbconfig, &config, fbconfig->alphaMask)) if (!chooseEGLConfig(ctxconfig, fbconfig, &config, fbconfig->transparent))
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig"); "EGL: Failed to find a suitable EGLConfig");
@ -738,7 +738,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
const long vimask = VisualScreenMask | VisualIDMask; const long vimask = VisualScreenMask | VisualIDMask;
if (!chooseEGLConfig(ctxconfig, fbconfig, &native, wndconfig->alphaMask)) if (!chooseEGLConfig(ctxconfig, fbconfig, &native, wndconfig->transparent))
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig"); "EGL: Failed to find a suitable EGLConfig");

View File

@ -64,6 +64,8 @@ static GLFWbool chooseGLXFBConfig(
findTransparent = GLFW_FALSE; findTransparent = GLFW_FALSE;
} }
findTransparent = GLFW_TRUE;
// HACK: This is a (hopefully temporary) workaround for Chromium // HACK: This is a (hopefully temporary) workaround for Chromium
// (VirtualBox GL) not setting the window bit on any GLXFBConfigs // (VirtualBox GL) not setting the window bit on any GLXFBConfigs
vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR); vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
@ -81,7 +83,7 @@ static GLFWbool chooseGLXFBConfig(
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig)); usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
usableCount = 0; usableCount = 0;
selectionloop: selectionloop:
for (i = 0; i < nativeCount; i++) for (i = 0; i < nativeCount; i++)
{ {
@ -99,25 +101,31 @@ selectionloop:
continue; continue;
} }
if( findTransparent ) { if( findTransparent ) {
XVisualInfo *visualinfo; XVisualInfo *visualinfo;
XRenderPictFormat *pictFormat; XRenderPictFormat *pictFormat;
visualinfo = glXGetVisualFromFBConfig(_glfw.x11.display, n); visualinfo = glXGetVisualFromFBConfig(_glfw.x11.display, n);
if (!visualinfo) if (!visualinfo) {
continue; printf("!visualinfo: bail\n");
continue;
}
pictFormat = XRenderFindVisualFormat(_glfw.x11.display, visualinfo->visual); pictFormat = XRenderFindVisualFormat(_glfw.x11.display, visualinfo->visual);
if( !pictFormat ) { if( !pictFormat ) {
XFree( visualinfo ); printf("!pictFormat: bail\n");
continue; XFree( visualinfo );
} continue;
}
if( !pictFormat->direct.alphaMask ) { if( !pictFormat->direct.alphaMask ) {
XFree( visualinfo ); printf("!pictFormat->direct alphaMask: bail\n");
continue; XFree( visualinfo );
} continue;
XFree( visualinfo ); }
printf("looking for transparent visual: didn't find\n");
XFree( visualinfo );
} }
u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE); u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
@ -150,7 +158,7 @@ selectionloop:
usableCount++; usableCount++;
} }
// reiterate the selection loop without looking for transparency supporting // 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 ) { if( findTransparent && !usableCount ) {
findTransparent = GLFW_FALSE; findTransparent = GLFW_FALSE;
goto selectionloop; goto selectionloop;
@ -722,4 +730,3 @@ GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
return window->context.glx.window; return window->context.glx.window;
} }

View File

@ -305,7 +305,6 @@ struct _GLFWwndconfig
GLFWbool floating; GLFWbool floating;
GLFWbool maximized; GLFWbool maximized;
GLFWbool centerCursor; GLFWbool centerCursor;
GLFWbool alphaMask;
struct { struct {
GLFWbool retina; GLFWbool retina;
GLFWbool frame; GLFWbool frame;
@ -349,7 +348,7 @@ struct _GLFWfbconfig
int redBits; int redBits;
int greenBits; int greenBits;
int blueBits; int blueBits;
int alphaMask; int transparent;
int alphaBits; int alphaBits;
int depthBits; int depthBits;
int stencilBits; int stencilBits;

View File

@ -213,8 +213,10 @@ static int choosePixelFormat(_GLFWwindow* window,
} }
u->handle = n; 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++; usableCount++;
} }
// Reiterate the selection loop without looking for transparency supporting // Reiterate the selection loop without looking for transparency supporting

View File

@ -147,13 +147,13 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
fbconfig = _glfw.hints.framebuffer; fbconfig = _glfw.hints.framebuffer;
ctxconfig = _glfw.hints.context; ctxconfig = _glfw.hints.context;
wndconfig = _glfw.hints.window; 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.width = width;
wndconfig.height = height; wndconfig.height = height;
wndconfig.title = title; wndconfig.title = title;
ctxconfig.share = (_GLFWwindow*) share; 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) if (ctxconfig.share)
{ {
@ -185,7 +185,6 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
window->transparent = wndconfig.transparent; window->transparent = wndconfig.transparent;
window->autoIconify = wndconfig.autoIconify; window->autoIconify = wndconfig.autoIconify;
window->floating = wndconfig.floating; window->floating = wndconfig.floating;
window->transparent = wndconfig.alphaMask;
window->cursorMode = GLFW_CURSOR_NORMAL; window->cursorMode = GLFW_CURSOR_NORMAL;
window->minwidth = GLFW_DONT_CARE; window->minwidth = GLFW_DONT_CARE;
@ -267,7 +266,7 @@ void glfwDefaultWindowHints(void)
_glfw.hints.framebuffer.depthBits = 24; _glfw.hints.framebuffer.depthBits = 24;
_glfw.hints.framebuffer.stencilBits = 8; _glfw.hints.framebuffer.stencilBits = 8;
_glfw.hints.framebuffer.doublebuffer = GLFW_TRUE; _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 // The default is to select the highest available refresh rate
_glfw.hints.refreshRate = GLFW_DONT_CARE; _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; _glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE;
return; return;
case GLFW_TRANSPARENT: case GLFW_TRANSPARENT:
_glfw.hints.framebuffer.alphaMask = value; _glfw.hints.framebuffer.transparent = value;
return; return;
case GLFW_SAMPLES: case GLFW_SAMPLES:
_glfw.hints.framebuffer.samples = value; _glfw.hints.framebuffer.samples = value;