Both chooseEGLConfig() and chooseGLXConfig() can also be reverted.

Since the findTransparent (GLFWbool) is sourced from the already
provided `fbconfig` anyways.
This commit is contained in:
Bailey Cosier 2017-09-18 00:59:12 +07:00
parent aa78533764
commit 9a2890d611
2 changed files with 12 additions and 17 deletions

View File

@ -87,13 +87,13 @@ static int getEGLConfigAttrib(EGLConfig config, int attrib)
// //
static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig, static GLFWbool chooseEGLConfig(const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* desired, const _GLFWfbconfig* desired,
EGLConfig* result, EGLConfig* result)
GLFWbool findTransparent)
{ {
EGLConfig* nativeConfigs; EGLConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs; _GLFWfbconfig* usableConfigs;
const _GLFWfbconfig* closest; const _GLFWfbconfig* closest;
int i, nativeCount, usableCount; int i, nativeCount, usableCount;
GLFWbool findTransparent = desired->transparent;
#if defined(_GLFW_X11) #if defined(_GLFW_X11)
XVisualInfo visualTemplate = {0}; XVisualInfo visualTemplate = {0};
@ -138,7 +138,7 @@ selectionloop:
int n_vi; int n_vi;
XVisualInfo *visualinfo; XVisualInfo *visualinfo;
XRenderPictFormat *pictFormat; XRenderPictFormat *pictFormat;
visualinfo = XGetVisualInfo(_glfw.x11.display, VisualIDMask, &visualTemplate, &n_vi); visualinfo = XGetVisualInfo(_glfw.x11.display, VisualIDMask, &visualTemplate, &n_vi);
if (!visualinfo) if (!visualinfo)
continue; continue;
@ -191,10 +191,10 @@ 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;
} }
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount); closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
@ -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->transparent)) if (!chooseEGLConfig(ctxconfig, fbconfig, &config))
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig"); "EGL: Failed to find a suitable EGLConfig");
@ -737,7 +737,7 @@ GLFWbool _glfwChooseVisualEGL(const _GLFWctxconfig* ctxconfig,
const long vimask = VisualScreenMask | VisualIDMask; const long vimask = VisualScreenMask | VisualIDMask;
if (!chooseEGLConfig(ctxconfig, fbconfig, &native, fbconfig->transparent)) if (!chooseEGLConfig(ctxconfig, fbconfig, &native))
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"EGL: Failed to find a suitable EGLConfig"); "EGL: Failed to find a suitable EGLConfig");
@ -804,4 +804,3 @@ GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* handle)
return window->context.egl.surface; return window->context.egl.surface;
} }

View File

@ -47,11 +47,7 @@ static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
// Return the GLXFBConfig most closely matching the specified hints // Return the GLXFBConfig most closely matching the specified hints
// //
static GLFWbool chooseGLXFBConfig( static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result)
const _GLFWfbconfig* desired,
GLXFBConfig* result,
GLFWbool findTransparent)
{ {
GLXFBConfig* nativeConfigs; GLXFBConfig* nativeConfigs;
_GLFWfbconfig* usableConfigs; _GLFWfbconfig* usableConfigs;
@ -59,6 +55,7 @@ static GLFWbool chooseGLXFBConfig(
int i, nativeCount, usableCount; int i, nativeCount, usableCount;
const char* vendor; const char* vendor;
GLFWbool trustWindowBit = GLFW_TRUE; GLFWbool trustWindowBit = GLFW_TRUE;
GLFWbool findTransparent = desired->transparent;
if ( !(_glfw.xrender.major || _glfw.xrender.minor) ) { if ( !(_glfw.xrender.major || _glfw.xrender.minor) ) {
findTransparent = GLFW_FALSE; findTransparent = GLFW_FALSE;
@ -155,7 +152,7 @@ selectionloop:
// 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;
} }
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount); closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
@ -481,8 +478,7 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
if (ctxconfig->share) if (ctxconfig->share)
share = ctxconfig->share->context.glx.handle; share = ctxconfig->share->context.glx.handle;
if (!chooseGLXFBConfig(fbconfig, &native, fbconfig->transparent)) if (!chooseGLXFBConfig(fbconfig, &native))
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig"); "GLX: Failed to find a suitable GLXFBConfig");
@ -669,7 +665,7 @@ GLFWbool _glfwChooseVisualGLX(const _GLFWctxconfig* ctxconfig,
GLXFBConfig native; GLXFBConfig native;
XVisualInfo* result; XVisualInfo* result;
if (!chooseGLXFBConfig(fbconfig, &native, fbconfig->transparent)) if (!chooseGLXFBConfig(fbconfig, &native))
{ {
_glfwInputError(GLFW_FORMAT_UNAVAILABLE, _glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"GLX: Failed to find a suitable GLXFBConfig"); "GLX: Failed to find a suitable GLXFBConfig");