From bd13f55ca8b220acb9484c4f97b39b6cbaf54be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 24 Apr 2022 22:31:28 +0200 Subject: [PATCH] WGL: Fix count of displayable pixel formats We only care about displayable pixel formats (as defined in WGL_ARB_pixel_format) for window context creation. This changes pixel format enumeration to ignore non-displayable formats, which are specified to be listed after displayable ones, by always using the return value of DescribePixelFormat as the pixel format count. (cherry picked from commit 2c0f34b60f7c7a07183ed71754b0156ece3b6c1b) --- src/wgl_context.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/wgl_context.c b/src/wgl_context.c index 72ad11de..a7704738 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -73,18 +73,13 @@ static int choosePixelFormat(_GLFWwindow* window, int attribs[40]; int values[sizeof(attribs) / sizeof(attribs[0])]; + nativeCount = DescribePixelFormat(window->context.wgl.dc, + 1, + sizeof(PIXELFORMATDESCRIPTOR), + NULL); + if (_glfw.wgl.ARB_pixel_format) { - const int attrib = WGL_NUMBER_PIXEL_FORMATS_ARB; - - if (!wglGetPixelFormatAttribivARB(window->context.wgl.dc, - 1, 0, 1, &attrib, &nativeCount)) - { - _glfwInputErrorWin32(GLFW_PLATFORM_ERROR, - "WGL: Failed to retrieve pixel format attribute"); - return 0; - } - addAttrib(WGL_SUPPORT_OPENGL_ARB); addAttrib(WGL_DRAW_TO_WINDOW_ARB); addAttrib(WGL_PIXEL_TYPE_ARB); @@ -122,13 +117,6 @@ static int choosePixelFormat(_GLFWwindow* window, addAttrib(WGL_COLORSPACE_EXT); } } - else - { - nativeCount = DescribePixelFormat(window->context.wgl.dc, - 1, - sizeof(PIXELFORMATDESCRIPTOR), - NULL); - } usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));