From 9a2890d611e367565c9f2955fbbe0f201f025d7d Mon Sep 17 00:00:00 2001 From: Bailey Cosier Date: Mon, 18 Sep 2017 00:59:12 +0700 Subject: [PATCH] Both `chooseEGLConfig()` and `chooseGLXConfig()` can also be reverted. Since the findTransparent (GLFWbool) is sourced from the already provided `fbconfig` anyways. --- src/egl_context.c | 15 +++++++-------- src/glx_context.c | 14 +++++--------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index 70ec35c38..ff8b8aedc 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -87,13 +87,13 @@ static int getEGLConfigAttrib(EGLConfig config, int attrib) // static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* desired, - EGLConfig* result, - GLFWbool findTransparent) + EGLConfig* result) { EGLConfig* nativeConfigs; _GLFWfbconfig* usableConfigs; const _GLFWfbconfig* closest; int i, nativeCount, usableCount; + GLFWbool findTransparent = desired->transparent; #if defined(_GLFW_X11) XVisualInfo visualTemplate = {0}; @@ -138,7 +138,7 @@ selectionloop: int n_vi; XVisualInfo *visualinfo; XRenderPictFormat *pictFormat; - + visualinfo = XGetVisualInfo(_glfw.x11.display, VisualIDMask, &visualTemplate, &n_vi); if (!visualinfo) continue; @@ -191,10 +191,10 @@ 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; + goto selectionloop; } closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount); @@ -492,7 +492,7 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, if (ctxconfig->share) share = ctxconfig->share->context.egl.handle; - if (!chooseEGLConfig(ctxconfig, fbconfig, &config, fbconfig->transparent)) + if (!chooseEGLConfig(ctxconfig, fbconfig, &config)) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Failed to find a suitable EGLConfig"); @@ -737,7 +737,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWctxconfig* ctxconfig, const long vimask = VisualScreenMask | VisualIDMask; - if (!chooseEGLConfig(ctxconfig, fbconfig, &native, fbconfig->transparent)) + if (!chooseEGLConfig(ctxconfig, fbconfig, &native)) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "EGL: Failed to find a suitable EGLConfig"); @@ -804,4 +804,3 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle) return window->context.egl.surface; } - diff --git a/src/glx_context.c b/src/glx_context.c index e48ef70fd..a6ce6e672 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -47,11 +47,7 @@ static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib) // Return the GLXFBConfig most closely matching the specified hints // -static GLFWbool chooseGLXFBConfig( - const _GLFWfbconfig* desired, - GLXFBConfig* result, - GLFWbool findTransparent) - +static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result) { GLXFBConfig* nativeConfigs; _GLFWfbconfig* usableConfigs; @@ -59,6 +55,7 @@ static GLFWbool chooseGLXFBConfig( int i, nativeCount, usableCount; const char* vendor; GLFWbool trustWindowBit = GLFW_TRUE; + GLFWbool findTransparent = desired->transparent; if ( !(_glfw.xrender.major || _glfw.xrender.minor) ) { findTransparent = GLFW_FALSE; @@ -155,7 +152,7 @@ selectionloop: // formats if no matchig FB configs for a transparent window were found. if( findTransparent && !usableCount ) { findTransparent = GLFW_FALSE; - goto selectionloop; + goto selectionloop; } closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount); @@ -481,8 +478,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window, if (ctxconfig->share) share = ctxconfig->share->context.glx.handle; - if (!chooseGLXFBConfig(fbconfig, &native, fbconfig->transparent)) - + if (!chooseGLXFBConfig(fbconfig, &native)) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "GLX: Failed to find a suitable GLXFBConfig"); @@ -669,7 +665,7 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWctxconfig* ctxconfig, GLXFBConfig native; XVisualInfo* result; - if (!chooseGLXFBConfig(fbconfig, &native, fbconfig->transparent)) + if (!chooseGLXFBConfig(fbconfig, &native)) { _glfwInputError(GLFW_FORMAT_UNAVAILABLE, "GLX: Failed to find a suitable GLXFBConfig");