瀏覽代碼

Move single/double-buffer filtering to backends

There is no need to enumerate framebuffer configs that will just be
filtered out later by the GLFW_DOUBLEBUFFER hard constraint.

(cherry picked from commit fd79b02840a36b74e4289cc53dc332de6403b8fd)
Camilla Löwy 4 年之前
父節點
當前提交
6769ffcd0f
共有 3 個文件被更改,包括 9 次插入12 次删除
  1. 0 6
      src/context.c
  2. 3 2
      src/glx_context.c
  3. 6 4
      src/wgl_context.c

+ 0 - 6
src/context.c

@@ -196,12 +196,6 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
             continue;
             continue;
         }
         }
 
 
-        if (desired->doublebuffer != current->doublebuffer)
-        {
-            // Double buffering is a hard constraint
-            continue;
-        }
-
         // Count number of missing buffers
         // Count number of missing buffers
         {
         {
             missing = 0;
             missing = 0;

+ 3 - 2
src/glx_context.c

@@ -92,6 +92,9 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
                 continue;
                 continue;
         }
         }
 
 
+        if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER) != desired->doublebuffer)
+            continue;
+
         if (desired->transparent)
         if (desired->transparent)
         {
         {
             XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
             XVisualInfo* vi = glXGetVisualFromFBConfig(_glfw.x11.display, n);
@@ -119,8 +122,6 @@ static GLFWbool chooseGLXFBConfig(const _GLFWfbconfig* desired,
 
 
         if (getGLXFBConfigAttrib(n, GLX_STEREO))
         if (getGLXFBConfigAttrib(n, GLX_STEREO))
             u->stereo = GLFW_TRUE;
             u->stereo = GLFW_TRUE;
-        if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
-            u->doublebuffer = GLFW_TRUE;
 
 
         if (_glfw.glx.ARB_multisample)
         if (_glfw.glx.ARB_multisample)
             u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
             u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);

+ 6 - 4
src/wgl_context.c

@@ -165,6 +165,9 @@ static int choosePixelFormat(_GLFWwindow* window,
             if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
             if (findAttribValue(WGL_ACCELERATION_ARB) == WGL_NO_ACCELERATION_ARB)
                 continue;
                 continue;
 
 
+            if (findAttribValue(WGL_DOUBLE_BUFFER_ARB) != fbconfig->doublebuffer)
+                continue;
+
             u->redBits = findAttribValue(WGL_RED_BITS_ARB);
             u->redBits = findAttribValue(WGL_RED_BITS_ARB);
             u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
             u->greenBits = findAttribValue(WGL_GREEN_BITS_ARB);
             u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
             u->blueBits = findAttribValue(WGL_BLUE_BITS_ARB);
@@ -182,8 +185,6 @@ static int choosePixelFormat(_GLFWwindow* window,
 
 
             if (findAttribValue(WGL_STEREO_ARB))
             if (findAttribValue(WGL_STEREO_ARB))
                 u->stereo = GLFW_TRUE;
                 u->stereo = GLFW_TRUE;
-            if (findAttribValue(WGL_DOUBLE_BUFFER_ARB))
-                u->doublebuffer = GLFW_TRUE;
 
 
             if (_glfw.wgl.ARB_multisample)
             if (_glfw.wgl.ARB_multisample)
                 u->samples = findAttribValue(WGL_SAMPLES_ARB);
                 u->samples = findAttribValue(WGL_SAMPLES_ARB);
@@ -239,6 +240,9 @@ static int choosePixelFormat(_GLFWwindow* window,
             if (pfd.iPixelType != PFD_TYPE_RGBA)
             if (pfd.iPixelType != PFD_TYPE_RGBA)
                 continue;
                 continue;
 
 
+            if (!!(pfd.dwFlags & PFD_DOUBLEBUFFER) != fbconfig->doublebuffer)
+                continue;
+
             u->redBits = pfd.cRedBits;
             u->redBits = pfd.cRedBits;
             u->greenBits = pfd.cGreenBits;
             u->greenBits = pfd.cGreenBits;
             u->blueBits = pfd.cBlueBits;
             u->blueBits = pfd.cBlueBits;
@@ -256,8 +260,6 @@ static int choosePixelFormat(_GLFWwindow* window,
 
 
             if (pfd.dwFlags & PFD_STEREO)
             if (pfd.dwFlags & PFD_STEREO)
                 u->stereo = GLFW_TRUE;
                 u->stereo = GLFW_TRUE;
-            if (pfd.dwFlags & PFD_DOUBLEBUFFER)
-                u->doublebuffer = GLFW_TRUE;
         }
         }
 
 
         u->handle = pixelFormat;
         u->handle = pixelFormat;