From 53f61e9596258bec2f3ead7516eee9fead39c310 Mon Sep 17 00:00:00 2001 From: binary1248 Date: Wed, 15 Apr 2015 00:46:21 +0200 Subject: [PATCH] Removed stricter Unix visual requirements for now and increased Windows pixel format array size from 256 to 512 to make sure all pixel formats are taken into consideration on systems that support that many. --- src/SFML/Window/Unix/GlxContext.cpp | 41 ++++++---------------------- src/SFML/Window/Win32/WglContext.cpp | 4 +-- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/SFML/Window/Unix/GlxContext.cpp b/src/SFML/Window/Unix/GlxContext.cpp index f342df0d..7b1f3fa6 100644 --- a/src/SFML/Window/Unix/GlxContext.cpp +++ b/src/SFML/Window/Unix/GlxContext.cpp @@ -308,42 +308,25 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe XVisualInfo* visuals = XGetVisualInfo(display, 0, NULL, &count); if (visuals) { - // There are no GLX versions prior to 1.0 - int major = 0; - int minor = 0; - - if (!glXQueryVersion(display, &major, &minor)) - err() << "Failed to query GLX version" << std::endl; - // Evaluate all the returned visuals, and pick the best one int bestScore = 0x7FFFFFFF; XVisualInfo bestVisual; for (int i = 0; i < count; ++i) { // Check mandatory attributes - int useGL, doubleBuffer, rgba; - glXGetConfig(display, &visuals[i], GLX_USE_GL, &useGL); + int doubleBuffer; glXGetConfig(display, &visuals[i], GLX_DOUBLEBUFFER, &doubleBuffer); - glXGetConfig(display, &visuals[i], GLX_RGBA, &rgba); - if (!useGL || !doubleBuffer || !rgba) + if (!doubleBuffer) continue; - if (major > 1 || minor >= 3) - { - int drawableType; - glXGetConfig(display, &visuals[i], GLX_DRAWABLE_TYPE, &drawableType); - if (!(drawableType & GLX_WINDOW_BIT)) - continue; - } - // Extract the components of the current visual int red, green, blue, alpha, depth, stencil, multiSampling, samples; - glXGetConfig(display, &visuals[i], GLX_RED_SIZE, &red); - glXGetConfig(display, &visuals[i], GLX_GREEN_SIZE, &green); - glXGetConfig(display, &visuals[i], GLX_BLUE_SIZE, &blue); - glXGetConfig(display, &visuals[i], GLX_ALPHA_SIZE, &alpha); - glXGetConfig(display, &visuals[i], GLX_DEPTH_SIZE, &depth); - glXGetConfig(display, &visuals[i], GLX_STENCIL_SIZE, &stencil); + glXGetConfig(display, &visuals[i], GLX_RED_SIZE, &red); + glXGetConfig(display, &visuals[i], GLX_GREEN_SIZE, &green); + glXGetConfig(display, &visuals[i], GLX_BLUE_SIZE, &blue); + glXGetConfig(display, &visuals[i], GLX_ALPHA_SIZE, &alpha); + glXGetConfig(display, &visuals[i], GLX_DEPTH_SIZE, &depth); + glXGetConfig(display, &visuals[i], GLX_STENCIL_SIZE, &stencil); if (sfglx_ext_ARB_multisample == sfglx_LOAD_SUCCEEDED) { @@ -356,14 +339,8 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe samples = 0; } + // TODO: Replace this with proper acceleration detection bool accelerated = true; - if (major > 1 || minor >= 3) - { - int caveat; - glXGetConfig(display, &visuals[i], GLX_CONFIG_CAVEAT, &caveat); - if (caveat == GLX_SLOW_CONFIG) - accelerated = false; - } // Evaluate the visual int color = red + green + blue + alpha; diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp index c36cb8c9..2a5f9bab 100644 --- a/src/SFML/Window/Win32/WglContext.cpp +++ b/src/SFML/Window/Win32/WglContext.cpp @@ -231,9 +231,9 @@ int WglContext::selectBestPixelFormat(HDC deviceContext, unsigned int bitsPerPix }; // Let's check how many formats are supporting our requirements - int formats[256]; + int formats[512]; UINT nbFormats; - bool isValid = wglChoosePixelFormatARB(deviceContext, intAttributes, NULL, 256, formats, &nbFormats) != 0; + bool isValid = wglChoosePixelFormatARB(deviceContext, intAttributes, NULL, 512, formats, &nbFormats) != 0; // Get the best format among the returned ones if (isValid && (nbFormats > 0))